ToolStripMenuItem: how can I dynam modify/insert for an onClick event

Add-in Express™ Support Service
That's what is more important than anything else

ToolStripMenuItem: how can I dynam modify/insert for an onClick event
 
5 States




Posts: 78
Joined: 2009-04-03
I am trying to dynamically create a list of items for ToolStripMenuItems.

I was able to successfully add and display them, but the critical piece is applying an onClick event to them. How can this be done?

In the Design portion, an entirely separate sub has to be written for each event, but I don't think I can dynamically create a sub in VB.Net (or can I?)

In any event, I was hoping that the ToolStripMenuItem class had an "onClick" method so that I can do something like:

dynamicallyAddedItem.onClick ="loadUrl('http://google.com')"

Does anyone know if this can be done?

Thanks!

5
Posted 22 Apr, 2009 21:12:11 Top
5 States




Posts: 78
Joined: 2009-04-03
progress!

I decided to add a new ToolStripMenuItem like:

Dim tsmi As System.Windows.Forms.ToolStripMenuItem toolStripmenuItem = New System.Windows.Forms.ToolStripMenuItem(text As STring, image as System.DrawingImage,onClick As System.EventHandler,name As String)

i just don't know how to create the System.EventHandler.

does anyone know what that would look like?

i was thinking:

Dim onClickHandler As System.EventHandler=???

Thanks!

5
Posted 22 Apr, 2009 21:57:31 Top
5 States




Posts: 78
Joined: 2009-04-03
I found it.

FYI, the system.event handler is declared like:


Dim onClickHandler As System.EventHandler= New System.EventHandler(AddressOf MyIEProject.ClassName)

where MyIEProject.ClassName is separately declared with the same arguments as the onclick, with sender and system.eventargs

HTH!

5
Posted 22 Apr, 2009 22:12:42 Top
5 States




Posts: 78
Joined: 2009-04-03
Okay, I hate to re-open this topic, but now I am seeing how I can dynamically set an "onHover" trigger for these dynamically created ToolStripMenuItems.

For example, let's say I wanted to dynamically create 26 ToolStripMenuItems, for each letter A-Z. Then, when the user "hovers" over one of the letters, I wanted it to trigger another sub which will populate that menu with entries that begin with that letter.

If this is possible, please let me know...

5
Posted 23 Apr, 2009 02:00:29 Top