Sign in to follow this  

Assigning Events to Dynamic Objects

This topic is 4270 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How would I create an event handler procedure in Visual Basic .net if I created a 10x10 array of Buttons at runtime? The IDE states that I cannot access the events on the button objects until I've intialized them (which means it won't compile). Any ideas?

Share this post


Link to post
Share on other sites
Define your event handler with no Handles, then create your dynamic button and use AddHandler to associate the event handler with it


For d As Integer = 0 To 14
Dim btn as Button = New Button()
AddHandler btn.DragEnter, AddressOf Button_DragEnter
AddHandler btn.DragDrop, AddressOf Button_DragDrop
mybuttons.Add(btn)
Next

Share this post


Link to post
Share on other sites

This topic is 4270 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this