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); } }
}