How to force paint after setting Enabled = false in Windows C # user control and not in WPF?

How to force paint after setting Enabled = false in Windows C # user control?

+4
source share
3 answers

Use the EnabledChange event for 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 on the form. Good luck

+6
source

If you use winforms:

 myControl.Invalidate(); myControl.Update(); 
0
source

If you're talking about WPF UserControl s, you can simply subscribe to your control's IsEnabledChanged event and call InvalidateVisual() in the event handler.

-1
source

All Articles