4
Answers

list view + contextmenustrip

mali

mali

16y
12k
1

Hii everyone

I try this code. The menu itself is working  but it's showing no matter where I right-click in the ListView.  how can i hide the contextmenu when the row is empty?

Thanks

private void listViewCalendar_MouseDown(object sender, MouseEventArgs e)

{

Point p = new Point(e.X, e.Y);

if (e.Button == MouseButtons.Right )

{

ListViewItem lvi = this.listViewCalendar.GetItemAt(p.X, p.Y);

if (lvi != null && listViewCalendar.SelectedItems.Count ==1)

{

this.myContext.Show(this.listViewCalendar, p);

}

}

}


Answers (4)