I use Window Form C#
My code
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 { }
}
}
But it not working sometimes.
How to have a contentmenu for listview and listviewitem?
val1 and val2 are integers values, if menu doesn’t come to the right position you can add some values in it to make it on the right position 🙂