Checking if Menu Item is Selected

mas7004
02-26-2004, 12:49 PM
Hi,

I am using a context menu and creating it during run time. I want to check if an individual menu item is selected. For exmaple:

if menuItem1.Selected = true then

...........

end if

There doesn't seem to be a property for this. Any suggestions how I can do this? My menu items are constantly changing during runtime, based on user interaction and thus are variable names (menuItem1, menuItem2...). Thus I can't create specific events for each one in my code.


Thanks, Matt

Bucky
02-26-2004, 03:03 PM
Ah, but you can create specific events in your code. Create event handlers
for all your menu clicks with the proper signature. Don't add the Handles
clause at the end of the sub.

Then, in your code, use AddHandler and RemoveHandler as you add and
remove your menu items to add and remove event handlers for the
menu items' events.

mas7004
02-26-2004, 03:13 PM
thanks for the reply. i don't think that will work because there are hundreds of possible menu clicks (depending on the user's interaction). only a fraction will show up each time the context menu is shown.

ideally, i would like something in my code that identifies the menuitem that is selected. i think in VB6 you could do this:

If MenuItem(MenuItem.SelectedItem) = "String" Then
:
:
:
End if

The "SelectedItem" property is not part of the ContextMenu control in .NET, so I am looking for an alternative.

Thanks Again,

Matt

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum