I am trying to add a context menu to a listbox when you right click an item.
I am not even sure if the right click function with working properly.
Here is the code:
private void lstSource_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
Console.WriteLine("Right Click");
}
}
Nothing prints to the console. Am I missing something?
Thanks.
Make sure you wire the event up (and the ListBox is enabled):
You can also have the designer wire up the event for you by selecting the ListBox and double-clicking on the MouseDown event in the Properties window (click on the lightning bolt).