WinForms TreeView - 如何手动“突出显示"节点(就像它被点击一样) [英] WinForms TreeView - how to manually "highlight" node (like it was clicked)

查看:49
本文介绍了WinForms TreeView - 如何手动“突出显示"节点(就像它被点击一样)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道如何让以编程方式选择的节点以图形方式进入选择"状态,就像用户点击它一样.SelectedNode 只会在内部选择这个.非常感谢!

I would need to know how to let the programatically selected node make graphically in the state "selected" like the user clicked on it. SelectedNode only makes this one internally selected. Thank you very much!

推荐答案

它没有突出显示的原因是树视图没有焦点.这是在我的测试表单上的按钮单击事件中:

The reason it does not show as highlighted is due to the tree view not having focus. This is in a button click event on my test form:

TreeView1.SelectedNode = TreeView1.Nodes(2);
TreeView1.Focus();

正确突出显示节点.如果您删除 Focus(); 调用它不会突出显示,直到您单击进入树视图(树视图中的任何位置,不一定在您要选择的节点上).

Which highlights the node properly. if you remove the Focus(); call it doesn't highlight until you click into the tree view (anywhere in the tree view, not necessarily on to the node that you want to be selected).

这篇关于WinForms TreeView - 如何手动“突出显示"节点(就像它被点击一样)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆