Events in dynamic loaded assembly

M

Martin Falta

Hi all,

I need a help with following problem. I need to create a menu from dynamic
loaded assembly on the main form of my application. The menu is created
succesfully, but the events of this menu, which are defined in the dynamic
loaded assembly, are not raised. How can I raise them?

Martin
 
G

Gabriele G. Ponti

Martin,

I don't know the details of your application, but when you add a MenuItem to
your menu you can specify the event handler:

mnu.MenuItems.Add("Item 1", New EventHandler(AddressOf mnu_Click))

If this doesn't work for you because you can get the address of the
procedure, you can use a common procedure for all the MenuItems events, then
using the Index property of the sender object you can at least find out what
was selected and take the appropriate actions.

For example:

' add items
mnu.MenuItems.Add("Item 1", New EventHandler(AddressOf mnu_Click))
mnu.MenuItems.Add("Item 2", New EventHandler(AddressOf mnu_Click))
mnu.MenuItems.Add("Item 3", New EventHandler(AddressOf mnu_Click))

Protected Sub mnu_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)

Dim i As Integer

' get index
i = sender.Index

' do something with i
' ...

End Sub

HTH,

Gabriele
 

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

Top