ColinOL

A Small Website

用户工具

站点工具


wiki:csharp:winform-sd-sb-cz

树的鼠标操作

private void treeView1_MouseClick(object sender, MouseEventArgs e)
{
    TreeNode node = this.treeView1.GetNodeAt(e.X, e.Y);
    if (node == null)
        return;
    if (this.treeView1.SelectedNode != node)
    {
        this.treeView1.SelectedNode = node;
    }
    if (e.Button == MouseButtons.Right) //右键单击
    {
        switch (node.Level)
        {
            case 0:
                //this.contextMenuStrip1.Show(this.treeView1, e.X, e.Y);
                break;
            case 1:
                //this.contextMenuStrip1.Show(this.treeView1, e.X, e.Y);
                break;
        }
    }
    else //左键单击
    {
    }
}
wiki/csharp/winform-sd-sb-cz.txt · 最后更改: 2018/02/03 20:42 (外部编辑)