473,385 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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

Jun 18 '07 #1
2 2063
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

"Kevin" <ke**********@lycos.co.ukwrote in message
news:11********************@n60g2000hse.googlegrou ps.com...
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
Jun 19 '07 #2
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

Jun 20 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: T.H.M | last post by:
This is the all code. Very simple and short. I need to populate a treeView in aspx page (web form) from XML file. I get en completion error:No overload for method 'TreeNode' takes '1' arguments ....
6
by: Brian Smith | last post by:
Is there a way to avoid the default action of TreeNode expansion/contraction caused by double click? I can add an event handler to pop up my properties dialog on double click, but it has the...
3
by: Uty | last post by:
(Originally posted this in VC++ section .. whoops I'm working on a series of projects which have a few things in common, which has been abstracted into an object we'll call ParentForm. I started...
3
by: feel | last post by:
Goin' crazy with this recursive function ported from delphi... I send a string like DirA/ DirB /DirC but i get in the treeView each one in a new node.Cant get the child node....!! -DirA -DirB...
2
by: adbarnet | last post by:
Hi, I'm a C++ developer coming fresh to c# for GUI development. For the project I'm working on, I need a specialised control (a treeview derivative) which would be very useful in other...
1
by: kiran | last post by:
I cratee a form to meet the fallowing requirement. 1. If any node is selected the corresponding checkbox should be checked 2. If any checkbox is clicked the corresponding node should be selected ...
2
by: BluDog | last post by:
Hi I have a UserControl called MyUserControl that has the following constructor and InitializeComponent (automatically generated by VS): Public Sub New() MyBase.New() 'This call is...
0
by: Tony Johansson | last post by:
Hello! I have a very specific question and that is about how to inherit a visual control for example the control System.Windows.Forms.TextBox without causing the environment to delete the...
12
by: Oleg Subachev | last post by:
I am moving from Delphi to C# and hve encountered the problem: I have the following classes and form Load event handler: public class class1 { public string S; public class1( string aS ) {...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.