开发者

selecting a node in a treeview, on select of a node in a separate treeview

开发者 https://www.devze.com 2023-01-10 23:12 出处:网络
So basically i have 2 treeviews running next to each other, one shows a list of drugs that someone might be on the next shows the latests prescription date for that drug.

So basically i have 2 treeviews running next to each other, one shows a list of drugs that someone might be on the next shows the latests prescription date for that drug.

what i am trying to achieve is someway of when the user selects a drug in treeview A, it highlights that drugs latest prescribe date in treeview B, however my attempts havent been successfull yet and so i turn to you guys for help :)

this is the code i have tried in in the after select event of treevie开发者_开发问答wA

 int selected = mainTree.SelectedNode.Index;
 secondTree.SelectedNode = secondTree.Nodes[selected];

which did nothing basically..

i am open to ideas, if i am honest i would prefer to in someway have both the drug name and last prescribe date in the same treeview, this would make it much tidier, but i am not sure if u can have 2 trees next to each other


The reason you can't see any nodes selected is probably because by default the TreeView control will hide the current selection when the control has lost focus. If you add secondTree.HideSelection = false; to your code, you'll be able to see the effect that you want.

However, saying that I can't help but think that there may be a better way. Can't you use a label in place of the second TreeView? Clicking a drug in the first TreeView would then just show the last prescribed date in the Label?

0

精彩评论

暂无评论...
验证码 换一张
取 消