Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET Interface and Graphics > Checking if Menu Item is Selected


Reply
 
Thread Tools Display Modes
  #1  
Old 02-26-2004, 01:49 PM
mas7004 mas7004 is offline
Newcomer
 
Join Date: Jan 2004
Posts: 20
Default Checking if Menu Item is Selected


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
Reply With Quote
  #2  
Old 02-26-2004, 04:03 PM
Bucky's Avatar
Bucky Bucky is offline
A+ Certified Nerd

Retired Leader
* Expert *
 
Join Date: Dec 2001
Location: East Coast
Posts: 1,763
Default

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.
__________________
If you're not part of the solution, you're part of the precipitate.
Reply With Quote
  #3  
Old 02-26-2004, 04:13 PM
mas7004 mas7004 is offline
Newcomer
 
Join Date: Jan 2004
Posts: 20
Default

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
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to show the selected item in a listview? Coen Interface and Graphics 1 09-26-2003 07:22 AM
Adding Checkable menu item to excel texasrsx Excel 1 04-24-2003 04:01 PM
Menu Item checking and Caption refreshing Dr Slue General 7 11-25-2002 04:22 PM
Few Questions dealing with pictures crazycheetah General 21 06-18-2002 12:08 AM
VB Menus John General 8 02-05-2002 10:31 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->