你不要放在BeforSelect在mouseDown事件中判断,然后设一个公共变量来记下它,每次都在mousedonw来判断并改变,然后在beforeSelect 事件中判断公共变量就好啦

解决方案 »

  1.   

    up,MouseButtons.Left左键.
    MouseButtons.Right右键.
      

  2.   

    private void treeView1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    if(e.Button == System.Windows.Forms.MouseButtons.Right)
    {
    if(this.treeView1.GetNodeAt(e.X,e.Y) == null)
    {
    this.treeView1.SelectedNode = null;
    }
    else
    {
    TreeNode tn = new TreeNode();
    tn = this.treeView1.GetNodeAt(e.X,e.Y);
    this.treeView1.SelectedNode = tn;
    this.treeView1.ContextMenu = this.contextMenu1;
    }
    }
    }