I am showing data in db by treeview. Every data has its own code and parent code (not a level). My showing algorithm step is like this
- Step 1 : find data which parent code is null (Root node)
- Step 2 : find data which parent code is step 1 (parent of step 1)
- step 3 : add 1,2 to treeView and show
- step 4 : when click node, find data which parent code is selected node
- step 5 : add step 4 as selected code`s child node
node1
└ node2 - click expand icon
└ node3
└ node4 - selected node
In this case, I can only check selected node(node4). So If I put a adding child node code in event click or expand/collapse, code is working on selected node(node 4), not a node 2.
This is why I using click event.
I want to check which node`s expand icon was clicked. In this example, what node i want to get is node2.
A ignorant but simple way is well... save all of node's status and compare before expanded with after. This way will take too long when number of nodes is large.
If there is other simple way to pick a node2, I want to know how I can find it.
Sorry for my poor explanation.