how to get child node of node of treeview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Parameswar Nayak
    New Member
    • Jul 2010
    • 7

    how to get child node of node of treeview

    I have a treeview having 3 levels.I need to get all level node tags separately which are checked.
    i.e
    parentnodetag={ 1,2...}
    childTag={7,9,8 ...}
    childOfChildTag ={9,10...}
    Can any one help me Thanks in advance.
  • Christian Binder
    Recognized Expert New Member
    • Jan 2008
    • 218

    #2
    I think the easiest way would be, if you use a Dictionary key=level, value=List of tags for this level
    Dictionary<int, List<object>> //if Tag is type object

    then you iterate over the treeview and store the checked items tags in the Dict.

    e.g.
    Code:
    void foo(Node n, int level) {
      if(Node.Checked)
        SaveTag(Node, level);
      foreach(Node child in Node.Childs)
        foo(child, level+1);
    }
    SaveTag would store the Tag of the passed Node in Dictionary.

    Comment

    Working...