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 |
|
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 |
|
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 |
|
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 |
|