I have 3 listboxes and on MouseDown event i want them to show same context menu but there items would differ on every different listbox click. For example:
- contextMenu when clicked on :listBox1
* should show: {Edit,Add Items}
- contextMenu when clicked on :listBox2
* should show: {Remove, Add Price}
- contextMenu when clicked on :listBox3
* should show: {something, Remove}
Following is the code i am using for listBox1:
private void MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
listBx_1.SelectedIndex = listBx_1.IndexFromPoint(e.Location);
if (listBx_1.SelectedIndex != -1)
{
listboxContextMenu_Opening();
}
}
}
private void listboxContextMenu_Opening()
{
listboxContextMenu.Items.Clear();
listboxContextMenu.Items.Add("Edit");
listboxContextMenu.Items.Add("Add Items");
}
Now i want listBox2 and listBox3 context menu(same menu for all three listBoxes) items to be added using MouseDown event , How could i achieve that? Suggestions are Welcomed!!