How are about this:
private void typedMenuItem_Click(object sender, EventArgs e)
{
MenuItem mnu=(MenuItem)sender;
switch(mnu.Name)
{
case "MenuName1":
//Do one thing
break;
case "MuniName 2":
//Do other thing
break;
...
...
}
}
> Hello,
>
[quoted text clipped - 15 lines]
>
> Jeronimo
Jeronimo Bertran - 12 Apr 2005 05:59 GMT
Thanks Norman,
The menu items are actually dynamic.. but I can make your suggestion work
by looking for the name on the collection...
thanks.
Jeronimo
"Jeffrey Tan[MSFT]" - 13 Apr 2005 02:06 GMT
Hi Jeronimo,
Thanks for your feedback!!
I am glad that you got what you want, but just as "Herfried K. Wagner
[MVP]" and I pointed, the MenuItem does not have a "Name" property, and the
compiler will generate error on building Name property. Actually, Name
property is added by the VS.net designer for only design-time usage. So I
suspect you actually used MenuItem.Text property, yes?
Anyway, if you need further help, please feel free to tell us. I will work
with you. Thanks
Best regards,
Jeffrey Tan
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Herfried K. Wagner [MVP] - 12 Apr 2005 15:35 GMT
"Norman Yuan" <NoOne@NoExist.No> schrieb:
> private void typedMenuItem_Click(object sender, EventArgs e)
> {
[quoted text clipped - 11 lines]
> }
> }
'MenuItem' doesn't have a 'Name' property.

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Herfried K. Wagner [MVP] - 13 Apr 2005 10:14 GMT
Addendum:
> 'MenuItem' doesn't have a 'Name' property.
You may want to use a menuitem extender to extend the 'MenuItem' class with
properties:
MenuItem Extender - add images and font support to your menu
<URL:http://www.codeproject.com/cs/menu/MenuExtender.asp>

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Hi Jeronimo,
Thanks for your post!!
I think Norman have provided you one option way: use MenuItem.Text property
to distinguish the items(In design-time, there is no Name property). This
makes sense, because normally, we will not use 2 menuitems with the same
text.
Also, if all the menuitems are the same parent's children, we may use Index
property to determine their position. But I think the Text property options
is better in your situation.
=====================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Jeronimo Bertran - 15 Apr 2005 01:02 GMT
Jeffrey...
yes, I used the text property and it worked fine.
Thanks again.
> Hi Jeronimo,
>
> Thanks for your post!!
"Jeffrey Tan[MSFT]" - 15 Apr 2005 02:27 GMT
Hi Jeronimo,
Oh, thanks for your feedback and confirmation :-). I am glad your problem
is resolved. If you need further help, please feel free to post. Thanks
Best regards,
Jeffrey Tan
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.