473,405 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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

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

Aug 15 '06 #1
3 2224
When i say:
I have 1 contextmenu with several buttons, i mean several menu items.
Mi************@gmail.com wrote:
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
Aug 15 '06 #2
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]
- mv*@spam.guard.caspershouse.com

<Mi************@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
>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

Aug 15 '06 #3
Yes. This definately helps. This is exactly what i was looking for.

Thanks!
Nicholas Paldino [.NET/C# MVP] wrote:
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]
- mv*@spam.guard.caspershouse.com

<Mi************@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
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
Aug 15 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Adam Right | last post by:
Hi, I am using contextmenustrip in my usercontrol in which there is a grid control associated with it. I added the rows below in the designer code, to create contextmenustrip with its...
3
by: Ron M. Newman | last post by:
Hi, I'm attaching a ContextMenuStrip to a listview. Debugging shows the menu is healthy with one item in it and that it's referred to by the "listview.ContextMenuStrip". However, right clicking...
7
by: Dave | last post by:
How do I get my ContextMenuStrip to receive key down preview events? I have the event hooked but I don't see the key strokes in the event? Dave
0
by: CodeButcher | last post by:
For whatever reason, I can't get a ContextMenuStrip to appear when I right-click a listbox. I've assigned the ContextMenuStrip1 to ContentMenuStrip in my listbox but the menu never shows. ideas?
1
by: Tony Johansson | last post by:
Hello! I have a System.Windows.Forms.MenuStrip with some ToolStripMenuItem. One of these ToolStripMenuItem is called saveMemberToolStripMenuItem. This one is defined like this...
9
by: horizon | last post by:
I have a single ContextMenuStrip (with a single menu item) associated with two ListViews, How do I determine which of the two ListViews the menu event occured on? I could probably find the control...
1
by: johnnypung | last post by:
I have a treeview opening a contextMenuStrip on right click. However the right click would not select the node that it right clicks on. How should I make it so the right click will select the node,...
9
by: =?Utf-8?B?Z2luYWNyZXNzZQ==?= | last post by:
Hi, I have a form (Form1) with a ContextMenuStrip (ContextMenuStrip1). If I pass Form1 to a Utility Sub with the following code: Public Sub Utility(theForm as Object) with theForm For Each...
2
by: eBob.com | last post by:
I've been working on an app which has an array of RichTextBoxes. And I have a context menu for the RTBs. The context menu has two levels; the first level has two items, "Load Sample Text File"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.