我使用Window構成C# 我的代碼如何使用listview和listviewitem的contentmenustrip? C#
private void ViewList_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
Point pt = ViewList.PointToScreen(e.Location);
ListViewItem item = ViewList.GetItemAt(pt.X, pt.Y);
if (item != null)
{
contextMenuStrip1.Enabled = true;
contextMenuStrip1.Show(pt);
}
//else { }
}
}
但是它有時不能工作。 如何爲listview和listviewitem創建一個contentmenu?
你是什麼意思_他有時不工作_? – 2011-04-24 14:40:24
當我在列表視圖上選擇項目時,右鍵單擊它打開內容菜單有時它不起作用。 – giaosudau 2011-04-24 14:47:40