tags:

views:

49

answers:

3

Hi,

How to force paint after setting Enabled = false in a C# windows usercontrol ?

A: 

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

Aurélien Ribon
A: 

If you are using winforms:

myControl.Invalidate();
myControl.Update();
LukeN
+1  A: 

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!

Homam
So before saying "Not WPF" Praveen, go check if there is a Winforms equivalent of what can be done in WPF. This answer is the same as the earlier one about WPF.
Aurélien Ribon
I didn't say that.
Homam