By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,160 Members | 1,143 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,160 IT Pros & Developers. It's quick & easy.

Context Menu Processing

P: n/a
Hello, I have 2 context menu's in which the processing logic for a couple of
the menu items is similar. I was wanting to set up a single procedure for
handling these menu items. My problem is identifying the source of the event.

I thought I would be able to access the MenuItem name, by converting the
"sender" object to a "MenuItem", but when I do, there is no "name" property.
How do I distinquish between to two different menu items in the same
procedure?

Thanks inadvance for your assitance!!!!!!

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 20 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hi Jim,

Aye, you're right about that name being missing. Strange, huh?

Fortunately you can use:
Select Case DirectCast (sender, MenuItem).Text

Regards,
Fergus
Nov 20 '05 #2

P: n/a
"Jim Heavey" <Ji*******@hotmail.com> schrieb
Hello, I have 2 context menu's in which the processing logic for a
couple of the menu items is similar. I was wanting to set up a
single procedure for handling these menu items. My problem is
identifying the source of the event.

I thought I would be able to access the MenuItem name, by converting
the "sender" object to a "MenuItem", but when I do, there is no
"name" property. How do I distinquish between to two different menu
items in the same procedure?


It depends on where you've declared the menu items. If you used the Form
designer, each item is a field of the Form. Assuming the code is within the
same Form:

If Sender Is MyFirstMenuItem Then

ElseIf Sender Is MySecondMenuItem Then

ElseIf...

End If
--
Armin

Nov 20 '05 #3

P: n/a
Hello,

"Jim Heavey" <Ji*******@hotmail.com> schrieb:
I thought I would be able to access the MenuItem name,
by converting the "sender" object to a "MenuItem", but when
I do, there is no "name" property. How do I distinquish between
to two different menu items in the same
procedure?


\\\
If sender Is Me.MenuItem1 Then
...
ElseIf sender Is Me.MenuItem2 Then
...
Else
...
End If
///

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #4

P: n/a
Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
Aye, you're right about that name being missing. Strange, huh?

Fortunately you can use:
Select Case DirectCast (sender, MenuItem).Text


Noitce that this will only work if there are not 2 menu items with the same
text but different functionality.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #5

P: n/a
Hi Herfried,

|| > Fortunately you can use:
|| > Select Case DirectCast (sender, MenuItem).Text
||
|| Noitce that this will only work if there are not 2 menu items
|| with the same text but different functionality

Within the same MenuItem_Click handler. ;-)

Regards,.
Fergus
Nov 20 '05 #6

P: n/a
Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
Noitce that this will only work if there are not 2 menu items
with the same text but different functionality


Within the same MenuItem_Click handler. ;-)


I am not really sure what the sense of the question is. On the one hand
same functionality whould be handled in the same handler, on the other hand
he wants to distinguish between the different menu items.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #7

P: n/a
Hi Herfried,

Maybe Jim'll tell us what these items do.

Regards,
Fergus
Nov 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.