creating an inherited treeview, but InitializeComponent is not called?!?

K

Kevin

If someone could try this little test I would be most greatful:

In a project, create a new class.
Make this class inherit from TreeView
Switch to designer mode and drop a ContextMenuStrip onto it.
Switch back to code mode and it will have created the variable for
ContextMenuStrip as you would expect, along with "Private Sub
InitializeComponent" for all the initialization stuff.

Now the problem is that normally the InitializeComponent sub is called
from the New sub of the class. However, in this case there is no New
sub because the designer hasn't created one, which means the
initialization code is never called unless you manually add one.

Is this just me being crazy, or is this a bug?

Thanks in advance
Kevin
 
A

Andrew Christiansen

Just call InitializeComponent from the constructor of your class. Because
you didn't create this class using a designer, it didn't automatically
generate the code to call InitializeComponent in the constructor.

- Andrew
 
K

Kevin

Hi Andrew,
Yes, thats what I have done, but I just would have thought that the
IDE would have been clever enough to work out that the
InitializeComponent is never called, and thus create a 'new sub'.
Thanks for you help
Kevin
 

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

Top