Great, this works.
A related questions. In the scenario I laid out, is it possible to have the
derived form told to "delete" the control eventhough the base is still
defining it. I have seen that I can change the properties of controls
defined in the base Form, but when I select one of those and try to remove
it from the designer, no good.
> Have you tried changing the Modifiers property of each control in the
> designer property grid? By default, all controls are private, which means
[quoted text clipped - 24 lines]
>>
>> Is this possible within the constraints of VS's designer support?
opellegr - 30 Jan 2008 15:23 GMT
You cannot remove members of a base class as far as I know. Once a member is
inherited it will always be present. In a way, it's as if a derived class is
an instance of two classes: one of the base class and one of itself.
Still, you could set the Visible property of the controls you do not want to
display to false. This would keep them from being displayed on the derived
form. It *might* be a memory-saver to dispose of them as well in your
derived constructor or Load event, but that could be a mistake if there's
anything in the base class that accesses the control. I'd test disposing the
control heavily before releasing something like that.
> Great, this works.
>
[quoted text clipped - 3 lines]
> defined in the base Form, but when I select one of those and try to remove
> it from the designer, no good.
Gregg Walker - 30 Jan 2008 16:29 GMT
> A related questions. In the scenario I laid out, is it possible to have
> the derived form told to "delete" the control eventhough the base is still
> defining it. I have seen that I can change the properties of controls
> defined in the base Form, but when I select one of those and try to remove
> it from the designer, no good.
You cannot delete controls (or any other properties, methods, fields) from
an inherited form (class). You could set the control's visible property to
false making it appear to be gone as opellegr replied.
However another option in this case is to use Item/Project Templates as
opposed to Class Inheritance. The templates can be used to create a new
form with a base set of controls you commonly use but also allow you to
delete controls, properities, methods and fields that you don't need for the
created instance.
I actually prefer templates over inheritance in most cases for common forms
and project types.
hth
--
Gregg Walker