c# - Identify the clicked node in the treeview node collection -


i have treeview. composed "i" parent nodes, , "j" child nodes. need identify "i,j" node clicked user. can node text show below, need identify node inside treeview node collection. how can that?

private void treeview1_nodemousedoubleclick(object sender, treenodemouseclickeventargs e) {     listview1.items.add(e.node.text); } 

for example: let's have tree 5 parents , each parent has 10 child nodes. click on first child node located in third parent. need receive (i,j) pair in case, (2,0).

renan

you can use index property of treenode position in treenodecollection. try this:

private void treeview1_nodemousedoubleclick(object sender, treenodemouseclickeventargs e) {    treenode parent = e.node.parent;    string = parent == null ? "no parent" : parent.index;    listview1.items.add(string.format("{0}:{1}",i,e.node.index); } 

note: suppose want show "no parent" when parent null. can handle in case (such discarding case).


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -