Reputation: 5628
I manually select my Node in Treeview:
treeView1.SelectedNode = treeView1.Nodes[0].Nodes[0].Nodes[0];
But I want to click it also, not only select, cause I load data from XML into Form, depended on which Node has been clicked..
How to do this clickevent on the specified Node?
Upvotes: 0
Views: 4717
Reputation: 781
To add to Saeed Amiri's answer, if you are using WinForms I think you need to add listeners to BeforeSelect
or AfterSelect
, instead of SelectedNodeChanged.
Upvotes: 2
Reputation: 22565
I suggest trigger fetching data by SelectedNodeChanged
, not onclick
, because may be user click on one node multiple times and every time should wait for fetching new data but in fact there isn't any changes in data, Also you should do functionality of fetching data in separate method not in events, in events you should just call them (kind of single responsibility principle:).
Upvotes: 1