dcsimg
Results 1 to 2 of 2
  1. #1

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,626

    Resolved [RESOLVED] Override TreeNode.Nodes.Add()

    Hey all,
    I have a class (myTreeNode) that inherits from TreeNode, and to myTreeNode I have added a class (customClass : IClonable) as a property.

    When I add myTreeNode to a tree TreeView, the default customClass is used. When myTreeNode is added to another myTreeNode.Nodes collection, the childNode's customClass need to assume a clone of the parents customClass.

    What I would like to do is override the Nodes.Add method from within the myTreenNode Class and clone the custom class there. I suppose I could override the entire Nodes collection and handle the Add, remove, etc methods, but all I need is to know when the child is added and have a reference to both the child and the parent at that time.

    Any "easy" way to do this?
    thanks for looking
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  2. #2

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,626

    Re: Override TreeNode.Nodes.Add()

    sometimes all you have to do is ask to get the answer.
    VB.Net Code:
    1. Public Class MyTreeNode
    2.    Inherit Treenode
    3.  
    4.    Public SUb AddNode(newNode as myTreeNode)
    5.      newNode.customClass = Me.customClass.Clone
    6.      me.Nodes.Add(newNode)
    7. End Sub
    8.  
    9. End Class
    Really isn't that difficult. Just took a little pie to get to.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.