Groups | Blog | Home
all groups > vb.net controls > november 2005 >

vb.net controls : Dynamic ToolstripMenuItem + No Events on Sub-Menu's


Steve Nesbit
11/9/2005 12:07:39 PM

The applciation I'm writing has dynamic right mouse menus.

They are constructed on the fly every time a right click is done.

All of the menus look great.

The problem is that sub-menu items don't seem to have a related event being
triggered so I'm left with no way to implement.

I want to trap all of the events in a single routine (the same event as the
1st level menu items) and use one of the properties to distinguish which one
was clicked. This should work just fine, once I figure out how to tell the
submenus what event to use.

I see on the add method that you can specify an "OnClick" handler, but
this is not offered when just adding a toolbarmenuitem to the DropDownItems
collection. You have to add just a few basic properties to get that
option.

So I looked at the toolbarmenuitem thoroughly and I still can't find a
property or method that will let me specifiy the handler.


Does anyone know how to do this?


Steve Nesbit
11/9/2005 2:14:49 PM
Well I've solved a part of the problem. I was creating new toolbar items
and adding them to the dropdownitems. It seems events can't be added to
each item, so I had to create a new contextmenustrip, add the dropdownitems
to that. Add an event handler to point it to the same method handling the
other level of the context menu . This now triggers the correct event for
the sub-menu.

However, I have one problem left!!!!

It seems that I can also select the upper level menu item (when the upper
level has drop down items). I obviously don't want this to happen. I want
to disable the event tied to the higher level menu item, if there are
sub-items...


ARG......This should be as easy as setting CanSelect = False, EXCEPT THAT
THE METHOD IS READONLY!!!!!!

Please help!!


[quoted text, click to view]

AddThis Social Bookmark Button