문제

I have options like "Add", "Delete" and "Update" in my ContextMenuStrip, which should pop up when the user right clicks on a ListView.

How can I make the Update menu disabled if there are no items in the list view?

도움이 되었습니까?

해결책 2

You can try using the MouseDown event:

void listView1_MouseDown(object sender, MouseEventArgs e) {
  if (e.Button == MouseButtons.Right) {
    updateToolStripMenuItem.Enabled = (listView1.Items.Count > 0);
  }
}

다른 팁

Use the ContextMenuStrip.Opening event..

if (ListBox1.Items.Count == 0) {
     ItemAToolStripMenuItem.Enabled = false;
}

http://i.imgur.com/8DlqvDZ.png

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top