Windows Forms’ GenerateMember

A little known, as far as I can tell from asking around, yet extremely useful property in the Windows Forms designer’s property grid is GenerateMember.

Defaulting to true, it decides whether a control/component gets declared as a field on the form (true) or as a local variable in the InitializeComponent method (false). Setting it to false helps you remove some of the ‘clutter’ from your form, like those labels you placed on it, that you know you’re never going to reference from your code. Now you don’t even have to give them meaningful names in case someone bumps into them.

Justin suggested it might have been a better idea to default this property to false, but after considering this, I tend to disagree – I find that most of the controls I place on a form are referenced from my code and I’d rather have too many controls available than wondering where they’d gone.


One thought on “Windows Forms’ GenerateMember

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s