menu items: how to add?

  • Thread starter Thread starter tmaster
  • Start date Start date
T

tmaster

I understand how to add a menu item at the current level:

Me.mnuTopics.MenuItems.Add("MenuItem1", AddressOf MenuClickhandler)

But, how do you add a child menu item to this level (in other words start a
sub-menu of the current menu level)?

Thanks
 
tmaster said:
I understand how to add a menu item at the current level:

Me.mnuTopics.MenuItems.Add("MenuItem1", AddressOf
MenuClickhandler)

But, how do you add a child menu item to this level (in other words
start a sub-menu of the current menu level)?

The add method returns a MenuItem object. Currently you are ignoring the
return value. Assign it to a variabl and do the same as above
(var.menuitems.add ...)
 
Hi Tmaster,

If I have such problems, one of the solutions to solve it is
- to look in MSDE
- do it with the designer and looks than what the designer did create.
- place a message here

Did you do it already with the designer?

(You can see that, if you do not know that by clicking on the + in Windows
Designer Generated Code

Cor
Me.mnuTopics.MenuItems.Add("MenuItem1", AddressOf
MenuClickhandler)
 
Hi Armin,

Did I made a message (in a sometimes) Armin Zingler style gives Armin an
answer.

:-))))

Cor
 
Sounds good. But, when I am handling a click, how do I reference the current
menu item (or how do I get its index)?

I think that this references the first item (at this level?):
MenuItem = mnuTopics.MenuItems.Item(0)

Thanks
 
tmaster said:
Sounds good. But, when I am handling a click, how do I reference the
current menu item (or how do I get its index)?

The 'sender' argument is the reference to the clicked item. Use
Directcast(sender, menuitem)
type type-cast the reference to a MenuItem reference, eg.:

dim mi as menuitem
mi = directcast(sender, menuitem)

Access mi here.


To compare references, use the Is comparison operator.
 
Back
Top