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
Post a Comment