I have an issue where the Visual Studio (2010) WinForms designer creates some controls (or at least their fields) globally in the designer file, and some inside the InitializeComponent method called from the constructor.
Does anybody know why the designer creates them locally in the method rather than globally and is there a way to stop it doing this?
It does this on some forms but not all and seems to only really happen to Label controls. The developers of the forms affected are sure they have done nothing differently.
I could fix this manually but would rather know the root of the problem. I need to be able to access the fields from another method which uses reflection to access the fields.
There is a Generate Member (in code,
GenerateMember) property that controls whether the control has a member field. (Not too surprisingly, hopefully). It should default totrue, but may have been set tofalsesomehow.