DLL From inheritance

B

bob

Hi,
VS2008
I have a DLL with a basic form for my App forms to derive from.
It only checks that a text box of the inheritor form has focus and
changes its fore colour.
It does not have any controls on its design surface.
I derived another form from this base form that has a split container
thinking that it would be a good base and not wanting to break any
apps that were based on the original basic form.

When creating a new inherited form in the main app I used the Add -
Windows Form - inherited Form. Then use the inheritance picker to
browse to the DLL.
Once my new form is created I found the design surface locked. i.e. I
can't drag any controls onto the main app form that derives from the
DLL SplitContainer form.

This is obviously by intention as little pad locks are showing up on
the edges of the split container and its propertiies are greyed out

In the object browser the base classes look OK. i.e. public
constructors.
This is my first serious attempt at using an inherited form from a
class library with a control on the surface.
Am I going about it the right way, is it simply a property I have
missed or am I misunderstanding inheritance with forms.

thanks
bob
 
P

Peter Morris

Why have a base form for this? I suspect you could achieve the same using

Application.Idle event
static Form.ActiveForm
Form.ActiveControl

and it would apply to all forms in your app without having to use
inheritance?
 
B

bob

Hi Peter,
Thanks for your reply.
This class library started life a while ago as a repository of useful
things.e.g. A registry writer reader, Event writer.
(I realise some of this is now available via .Net framework )
I added the baseform sometime ago when I found the code for changing
the colour of a focused text box of the inheriting form. (My thanks
to the author). The Split Container version just seemed a natural
extension.
I am more concerned that I am missing a basic principle here.
What I am trying to do seems reasonable (to me) yet it would appear to
be wrong.
So essentially I am not looking for a way to solve this particular
app. But guidance on whether this is a feasible path to go down.
i.e. A class library of favourite baseforms. A one stop shop for
starting most of my forms.
thanks
Bob
 
P

Peter Morris

So essentially I am not looking for a way to solve this particular
app. But guidance on whether this is a feasible path to go down.
i.e. A class library of favourite baseforms. A one stop shop for
starting most of my forms.

What happens when you want some of what is in Form1 + some of what is in
Form2 + the highlight functionality? That's why it's usually better to use
composition than inheritance.
 
B

bob

Hi Pete,
Most of my apps are so different I usually start from a clean sheet of
paper. Even the 'coloured' text box rarely gets used. It is the
ancillary functions that usually make it worthwhile to reference the
library.
So I am not in a position where I can comment on the pros and cons of
composition vs inheritance.
I am just curious as to why the design surface is locked off using the
class library inherited form. The inheritance functionality is there
from a IDE point of view, yet, unless I am doing something wrong, it
appears to be less than useful.

regards
Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top