Sign in to follow this  
DragonGeo2

Assigning Events to Dynamic Objects

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

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