Jump to content
  • Advertisement
Sign in to follow this  
DragonGeo2

Assigning Events to Dynamic Objects

This topic is 4554 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
Advertisement
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
Guest Anonymous Poster
Thanks, it worked!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!