How to force paint after setting Enabled = false in a C# windows usercontrol, not WPF?
How开发者_StackOverflow社区 to force paint after setting Enabled = false in a C# windows usercontrol ?
Use EnabledChange
event for the UserControl..
private void userControl_EnabledChanged(object sender, EventArgs e)
{
if (! Enabled)
Invalidate(); // ask the control to redraw itself
}
Note: put this code inside the userControl class, not in the form. Good luck!
If you are using winforms:
myControl.Invalidate();
myControl.Update();
If you're talking about WPF UserControl
s, you can just subscribe to the IsEnabledChanged
event of your control and call InvalidateVisual()
in the event handler.
精彩评论