0
I tried this way:
private void listBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
contextMenuStrip1.Show(listBox1.PointToScreen(new Point(e.X, e.Y)));
}
}
But I need it to be the items on the listbox not the entire listbox, how can I do it?
You are trying to prevent the menu from being shown when you click on an area that has no items?
– Isac
Yes that’s right.
– user92401
Why don’t you test the
SelectedIndex
ofListBox
? With this you can know if you have a selected one and open the menu in relation to what is selected.– Isac