winform treeview 快速定位

treeview 树节点很多时
需要快速定位节点
1、考虑到这样的需求设计出如下解决方案
用户在文本框中输入需要查找的姓名
将他选中,文字粗体显示
2、 操作如下
创建事件
 
  private void tvOrgPersons_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (this.m_prevSelectedNode != null)
            {
                this.m_prevSelectedNode.NodeFont = null;
            }
            if (this.tvOrgPersons.SelectedNode!=null)
            {
                this.tvOrgPersons.SelectedNode.NodeFont = new Font(this.tvOrgPersons.Font, FontStyle.Bold);
                this.m_prevSelectedNode = this.tvOrgPersons.SelectedNode;
            }
 
                    }
 
设定树节点属性,使选中节点出现在可见区域




原文地址:https://www.cnblogs.com/zuifengke/p/3044226.html