Winform TreeView 单选

 private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
        {
            //通过鼠标或者键盘触发事件,防止修改节点的Checked状态时候再次进入
            if (e.Action == TreeViewAction.ByMouse || e.Action == TreeViewAction.ByKeyboard)
            {
                if (e.Node.Checked)
                {
                    foreach (TreeNode node in treeView1.Nodes)
                    {
                        if (node.Name != e.Node.Name)
                        {
                            node.Checked = false;
                        }
                    }
                }
            }
        }

 

posted @ 2015-01-09 16:03  奇风★逍遥  阅读(1643)  评论(0编辑  收藏  举报