Same ContextMenuStrip assigned to two listviews.. How do i tell which one called it?

M

Michael.Suarez

I have 1 contextmenu with several buttons.

two different listviews sit beside each other on the same form. Both
use the same context menu.

I have a method for when a menu item gets clicked:

private void mnuMapNew_Click(object sender, EventArgs e)
{

}


The sender in this case is the menu item, not the listview...

how can i grab hold of which listview was clicked to pop the menu to
lead to this item being clicked from within this method.

Any help greatly appreciated.
Thanks,
Mike
 
M

Michael.Suarez

When i say:
I have 1 contextmenu with several buttons, i mean several menu items.
 
N

Nicholas Paldino [.NET/C# MVP]

Michael,

You might want to try the SourceControl property. The documentation
states:

The control that caused this ContextMenuStrip to be displayed.

Hope this helps.
 
M

Michael.Suarez

Yes. This definately helps. This is exactly what i was looking for.

Thanks!

Michael,

You might want to try the SourceControl property. The documentation
states:

The control that caused this ContextMenuStrip to be displayed.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I have 1 contextmenu with several buttons.

two different listviews sit beside each other on the same form. Both
use the same context menu.

I have a method for when a menu item gets clicked:

private void mnuMapNew_Click(object sender, EventArgs e)
{

}


The sender in this case is the menu item, not the listview...

how can i grab hold of which listview was clicked to pop the menu to
lead to this item being clicked from within this method.

Any help greatly appreciated.
Thanks,
Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top