all groups > visual studio .net general > february 2006 >
You're in the

visual studio .net general

group:

Forms Inheritance and its baggage!


Forms Inheritance and its baggage! essgee
2/28/2006 11:10:27 PM
visual studio .net general:
Inheriting Forms (aka Visual Inheritance) is quite useful. However, I have
found VS2005 facilitation of this feature a little bit quirky. (It may also
be true for VS2003)

Firstly one has to presume that some controls on the base Form will be
declared as Protected. (Purists may argue against it and would suggest
exposing only via get/set etc.) There is no problem creating an inherited
Form, but as soon as you want to add additional controls, some undesirable
baggage may start appearing in InitializeComponent. It appears that along
with the Protected Control from the base Form, its state is also hauled in.
For example, a protected comboBox which is being populated (from Database) by
Form_Load event, will have values added statically (using AddRange) in the
InitializeComponent. Why?! Yes, the combobox needs populating but that should
happen when constructor for the base Form is run (and at that time values in
the underlying database may be different). Moreover this stuff will hang
around until you do a further control change to the derived Form that
triggers InitializeComponent rearrangement.

These AddRange statements do give errors as AddRange and DataSource mode of
operation for comboBoxes are not compatible. But the key question is why the
runtime attributes need to be forced-in at the design time.
Re: Forms Inheritance and its baggage! Kevin Spencer
3/1/2006 8:31:01 AM
[quoted text, click to view]

Nothing "needs to be forced-in at the design time." The .Net platform has
all kinds of support for customizing the design-time behavior of your custom
Controls, including Forms. If you don't like the default behavior, change
it.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
A brute awe as you,
a Metallic hag entity, eat us.


[quoted text, click to view]

Re: Forms Inheritance and its baggage! essgee
3/1/2006 4:51:28 PM
Hi Kevin

As you might have gathered I am a bit raw in this field, a further pointer
will be much appreciated. I did look in Tools->options, could not home in to
required area. Am I completely off target?!

AddThis Social Bookmark Button