2010-05-25 28 views

回答

8

將ContextMenuStrip屬性重置爲(無)。實現MouseUp事件處理程序並使用ListView.HitTest()來找出它被點擊的位置。例如:

private void listView1_MouseUp(object sender, MouseEventArgs e) { 
     if (e.Button == MouseButtons.Right) { 
      var loc = listView1.HitTest(e.Location); 
      if (loc.Item != null) contextMenuStrip1.Show(listView1, e.Location); 
     } 
    } 
+0

只是讓你知道,它沒有工作,當我右鍵單擊我沒有得到正確的單擊選項(編輯)。我想知道爲什麼。我試圖找出它,一旦我得到它會讓你知道。任何更多的建議將不勝感激 – peace 2010-05-25 11:23:54

+0

嗯,那裏沒有失敗模式,除了沒有正確設置MouseUp事件。使用屬性窗口中的閃電圖標。 – 2010-05-25 11:26:56

+0

工作!這是我的錯誤,我選擇了MouseUp在錯誤的控制...謝謝! – peace 2010-05-25 11:52:25

相關問題