Adding property's ?

G

Guest

I need to add a string property to a TreeNode object. One way
I can do this is to use the tag property. Here is my question,
can I do it this way, create a new class e.g. MyTreeNode which
inherits from TreeNode and adds what I need. Will such
an object be compatible with TreeView and TreeNodeCollection?

thanks
 
J

Jay B. Harlow [MVP - Outlook]

Renee,
I commonly inherit from TreeNode to add custom properties, inherited
TreeNodes are still TreeNodes and will work with TreeNodeCollection.

The "caveat" is that you need to cast your specific TreeNode to the specific
type when you access it from TreeNodeCollection.

Hope this helps
Jay

<Renee> wrote in message |I need to add a string property to a TreeNode object. One way
| I can do this is to use the tag property. Here is my question,
| can I do it this way, create a new class e.g. MyTreeNode which
| inherits from TreeNode and adds what I need. Will such
| an object be compatible with TreeView and TreeNodeCollection?
|
| thanks
|
|
 
G

Guest

Jay, I have done this, added a property to MyTreeNode, and then globaly
searched and replaced all the TreeNodes to MyTreeNodes, and now the
program doesn't work any more, any ideas?
 
J

Jay B. Harlow [MVP - Outlook]

Renee,
| and now the
| program doesn't work any more, any ideas?
What specifically do you mean "doesn't work any more".

Is there a specific Exception you are getting?

A specific compile error you are getting?

Can you show 10 to 15 lines of code that identifies the problem you are
having?

Hope this helps
Jay



<Renee> wrote in message | Jay, I have done this, added a property to MyTreeNode, and then globaly
| searched and replaced all the TreeNodes to MyTreeNodes, and now the
| program doesn't work any more, any ideas?
|
| > Renee,
| > I commonly inherit from TreeNode to add custom properties, inherited
| > TreeNodes are still TreeNodes and will work with TreeNodeCollection.
| >
| > The "caveat" is that you need to cast your specific TreeNode to the
| specific
| > type when you access it from TreeNodeCollection.
| >
| > Hope this helps
| > Jay
|
|
|
 
G

Guest

No there is no exception, the program compiles and run fine, but my
treeview is not being filled with the nodes, i.e. the program is
running, but not doing what it is supposed to. I shall have to do
debugging, I'll let you know what it was when I find the problem.

tnx
 

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