c# - How to change modifier of a control to Static in Visual Studio -
when create control drag , drop vs automatically generate code this:
public system.windows.forms.label label1;
when want change modifier of control static, go form1.designer.cs , edit to:
public static system.windows.forms.label label1;
it's ok. when modify every control, vs automatically change origin :(. how change modify of control static ?
sorry, im bad @ english :(
code comment:
public static void setlabelinfovisible(bool visible) { if (form1.labelinfo.invokerequired) { setlabelinfovisibledelegate del = new setlabelinfovisibledelegate(setlabelinfovisible); form1.labelinfo.invoke(del, new object[] { visible }); } else { form1.labelinfo.visible = visible; } }
designer code not supposed user modified, gets re-written visual studio every time make changes form in designer (as have discovered).
one way forward move control declaration , initialization non designer code file. however, means control no longer appear in designer.
edit: not way make controls accessible other threads! can't think of valid reason make control static.
Comments
Post a Comment