.NET Windows Forms design time rules

后端 未结 5 1084
我在风中等你
我在风中等你 2020-12-30 08:53

I have an object that starts a thread, opens a file, and waits for input from other classes. As it receives input, it writes it to disk. Basically, it\'s a thread safe data

5条回答
  •  一生所求
    2020-12-30 09:26

    Well, since this has been resurrected anyway, here's the function I use to determine whether I'm in design mode:

    public static bool IsAnyInDesignMode(Control control){
        while(control != null){
            if(control.Site != null && control.Site.DesignMode)
                return true;
            control = control.Parent;
        }
        return false;
    }
    

    This handles the case where the control is a child created by another control. The DesignMode property is only set for controls created by the designer itself.

提交回复
热议问题