C# treeview 使用笔记

treeView默认 展开
treeView1.ExpandAll();

treeview判断点击节点:

private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (treeView1.SelectedNode.Name == "节点名")
            { 
                frm_cluster.ShowDialog();
            }
}

 treeview 点击已经选过的节点如何触发事件:

  private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (treeView1.SelectedNode.Name == "cluster")
            {
                frm_cluster.ShowDialog();
            }
            treeView1.SelectedNode = null;
        }

在AfterSelect事件的末尾处,添加:treeView1.SelectedNode = null;

posted @ 2016-08-27 00:39  你且浅笑相安  阅读(1973)  评论(0编辑  收藏  举报