How to select the child node in TreeView in c# windows form -


i have 1 tree view in windows form. use following function select node in treeview.

private void findandselect(treenodecollection collection, object toselect)     {         //problem in line becouse while converting toselect istructuredentity showing null.          var entitytoselect = toselect decoupling::istructureentity;          if (entitytoselect == null) //just select structure root         {             _treeview.selectednode = _treeview.nodes[0];             return;         }         foreach (treenode tn in collection)         {             var treenodeentity = tn.tag istructureentity;             if (treenodeentity != null && treenodeentity.id == entitytoselect.id)             {                  _treeview.selectednode = tn;              }              findandselect(tn.nodes, toselect);         }     } 

but above function able select parent node in treeview , want select , highlight child. can please guide me need change work?

treeview.nodes give parent nodes. might have implement parentnode.childnode childnodes in tree. click here more info

foreach (treenode tn in treeview1.nodes) {    // parent node here    foreach (treenode child in tn.nodes)    {      //get child node here    } } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -