开发者

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 UserControls, you can just subscribe to the IsEnabledChanged event of your control and call InvalidateVisual() in the event handler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜