TreeList属性设置以及右键菜单实现

AllowSort = False,//关闭排序

AllowEdit = False//不能编辑

--------右键菜单实现

添加右键流程:

1.先在窗体上拖两个控件,分别是popupMenu和barManager

2.barManager中绑定form属性为当前窗体名称

3.点击barManager右键选择customize,可直接添加子菜单,如果需要有工具栏、菜单栏、状态栏、怎选择Designer,可添加,然后在选择customize,添加command命令,再command选中菜单中执行命令

4.绑定右键菜单事件:在MouseDown事件中处理事件

--右键菜单出现的位置

private void tlstEquipment_MouseClick(object sender, MouseEventArgs e)
  {if (e.Button == MouseButtons.Right)
       {
           System.Drawing.Point p = new System.Drawing.Point(MousePosition.X, MousePosition.Y);
           popupMenuTree.ShowPopup(p);
        }
       }
}

猜你喜欢

转载自www.cnblogs.com/yourSixUncle/p/9983631.html
今日推荐