将 TreeNode 分配给 TreeView 并显示为选定状态
嗨,
我有 TreeNode trn
它包含树节点及其一些子节点。 现在我想从另一个方法将此节点传递给 TreeView 树
,并且我想将 trn
显示为 TreeView 树
中选定的树节点。
(trn
可能每次都会根据用户的选择而改变)
我尝试过使用,
tree.SelectedNode = trn;
但它给了我荒谬的结果,例如有时突出显示另一个节点或有时仅突出显示根节点等。
我们有吗TreeNode 的索引,因此如果我获得任何节点的索引,那么我将只使用
tree.SelectedIndex = index;
但我不确定 TreeNode 是否真的存在 SelectedIndex ?
任何帮助
问候,
Sangram Nandkhile
HI,
I have TreeNode trn
which is containing treenode with some of its child nodes.
Now i want to pass this node to TreeView tree
from another method and i want to the show the trn
as selected tree node in the TreeView tree
.
(trn
is likely to change every time as per the selection by user)
I have tried using
tree.SelectedNode = trn;
but it is giving me absurd result like sometimes highlighting another node or sometimes highlighting the Root node only etc.
Do we have indexes for treeNode so if i get index of any node so i will just use
tree.SelectedIndex = index;
But i am not sure that SelectedIndex really exists for TreeNode ?
Any help
Regards,
Sangram Nandkhile
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个。
try this one.