C#彈出ContextMenuStrip菜單時禁用某些選項
//菜單彈出前根據條件禁用某些菜單
private void CmsRoomRightBtn_Opening(object sender, CancelEventArgs e)
{
UCRoomInfo.RoomInfo room = (UCRoomInfo.RoomInfo)cmsRoomRightBtn.SourceControl; //獲取與ContextMenuStrip關聯的控件,如 button (此處是我本人的自定義控件)
//禁用某些菜單
鎖定ToolStripMenuItem.Enabled = false;
}