Inheritance

  • Thread starter Thread starter Martin Horn
  • Start date Start date
M

Martin Horn

Can someone suggest a good tutorial on inheritance of graphical classes,
i.e. VB Form Classes, or are there known issues with this, as I seem to be
running into all sorts of unexpected problems.

I apologise if this is the second time I have posted this question, but the
first time it didn't show up in my newsgroup reader so I'm not certain it
posted properly.

Thanks,

Martin.
 
I hope this helps?

Cor

Well not entirely, no :(

Let me explain the situation in more detail. I have a requirement in my
program for two dialogs that are essentially the same layout, and only
differ by the a couple of buttons and some underlying code.

I would therefore like to have a base class with the common design and
common code and then have two child classes inherit this base class, so I
can add the extra buttons and code specific to the child class.

Let's assume I have defined a base class called OrderForm, I then create
another class as follows:

Public Class SaleForm
Inherits OrderForm
End Class

If I then try to view the Form designer for SaleForm I get errors something
along these lines in the design view window, so I can't add any controls to
it at design time.
------------------------------------------------
One or more errors encountered while loading the designer.The errors are
listed below. Some errors can be fixed by rebuilding your project, while
others may require code changes. Clicking on each error will take you to the
line of code that caused it.

Object reference not set to an instance of an object.
Hide
Edit

at System.ComponentModel.Design.DesignSurface.get_View()
at
Microsoft.VisualStudio.Shell.Design.WindowPaneProviderService.CreateWindowPane(DesignSurface
surface)
at
Microsoft.VisualStudio.Design.Serialization.CodeDom.DeferrableWindowPaneProviderService.CreateWindowPane(DesignSurface
surface)
at
Microsoft.VisualStudio.Design.VSDesignSurface.Microsoft.VisualStudio.Designer.Interfaces.IVSMDDesigner.get_View()
----------------------------------------------
This doesn't always happen, sometimes the child class will display in the
form designer as expected, then next time I load the project, I get the
above error or something similar.

The program compiles and runs without any problems, and I suppose I could
add the extra controls at runtime, but it would be nice to do it graphically
at design time.

Am I missing something obvious that is causing this?

Thanks,

Martin.
 
I think I have tracked down the problem...

It seems that if I have code (that references an object) in the OnLoad event
of the base class this is when I get problems with the designer for the
child class. Once removed everything seems to be fine. Does this make sense
or is it just a lucky coincidence?

Thanks.
 
Martin,

And what is than the reason you don't use the build in feature as I tried to
show you?

Add Inherited form, it asks you which form to inherit and does the rest.

Cor
 
Hi Cor,

it wasn't so much a problem with the actual inheritance, it was that the
designer for the child class wouldn't show due to a missing object
reference, so I couldn't add to the child class graphical interface at
design time. But it seems to have been caused by code in the OnLoad event of
the base class, which I have now removed and everything seems to be working
as expected.

Thanks for your help.
 

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


Back
Top