Dynamic menu and item clicked

W

William LaMartin

I recall being able to do this in Vb.net, but I can seem to find a way to
accomplish it in the compact framework.

I want to connect to a compact SQL database, get the list of tables and
display them in a menu. I have no trouble doing this. My problem begins
when I want to retrieve the text of the menu item when one of these
dynamically created menu items is clicked.

In VB.net I could add an item to the menu as follows.

mnuMain.MenuItems.Add("Menu Caption", AddressOf MenuItem_Click)

That allowed me to associate handler for the click event. However, in the
compact framework I can only add a Windows.Forms.MenuItem--with no method
that I see of associating a click event handler.

What is my solution?
 
D

Daniel Moth 2

Your solution is to add an event handler to the menuitem (with
AddHandler) before adding it to the collection.

Cheers
Daniel
 
W

William LaMartin

Thanks very much. That did the trick.

Daniel Moth 2 said:
Your solution is to add an event handler to the menuitem (with
AddHandler) before adding it to the collection.

Cheers
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Dynamic ContextMenu 4
Popup Menu 2
menu click event not firing 1
Accessing Sub Menu Items 5
Dynamic AddressOf value for AddHandler 1
Context Menu on ListBox 1
Hook menu item event 1
Simulate a Menu Click Event 4

Top