GenerateMember

Posted Mon, Aug 9 2004 0:42 by bill

Windows.Forms in Whidbey includes a new design time property you can set on controls.  This property is named GenerateMember.  Set it to False, and instead of the usual field generated for the control, it only gets declared inside the InitializeComponent method.  So this un-clutters your object’s fields.  You can still reference the object but you would have to iterate through it’s container object’s Controls collection.
Interestingly enough you can still hook up events for the control via the designer, and the AddHandler code is also added inside the InitializeComponent method.

For VB.NET this is a departure from the generated Property that is created for each WithEvents variable.

The good thing about this is the clutter removal.  For static labels, you really don’t need them as fields.  So this is kind of cool …

But …

Yes, I know, you were waiting for the criticism right ?  Well yep, this again is one of those so close but yet so far kind of implementations.  It’s great being there, but why can’t I set defaults for each control ?  I mean really, why doesn’t winforms use best practices and read defaults from a config file ? ;)

I would really like a config file where I can add a control to it specified by type, and set the default for members like this.  For example I would add
<control name=”System.Windows.Forms.Label”>
    <GenerateMember=False>
    <DefaultPrefix=”lbl”>
    <Accessibility=”Private”>
</control>
   
Really, how hard is it for these designers to read config files and if the type is in there, use those settings as default ? 
Hey, if I say Mark Boulter three times really loud do you think that will invoke him on this thread ???

Seriously, just that little extra can make a HUGE difference in productivity.


 

Filed under: , ,

Comments

# re: GenerateMember

Thursday, August 12, 2004 7:03 AM by bill

Other that the default prefix, that's definitely something I would use.

(The prefix dosen't matter to me because iot would take longer to select all the text expect the prefix than it would to type the extra three characters.)