[Resolved]Dynamically adding event args?
Hello,
If someone could point me in the right direct for this one, I would be jump up and down with joy, proclaiming your handle at the top of my lungs!
Now, on to the question: Is there a way to add event args dynamically. Here's what I mean:
I create a picturebox, and add it to a panel on the fly. I want it to be able to drag and drop. Also, I to create pictureboxes with onDragEnter do this, but because this is all dynamically created, I have no clue how to do this...
:-(. If I haven't explained clearly, plz let me know and I'll get into it more.
Thanks,
Mike
Re: Dynamically adding event args?
Check out the AddHandler method. You can write a generic sub that covers all the particular ondrag events for pictureboxes, and then use the sender variable to perform the sub's action on your specific picturebox.
Bill
Re: Dynamically adding event args?
I hate to ask, but can you give me an example of how this works, something simple like if i drag a little square into a large circle it pops a messagebox("CIRCLE!!!") and if i drag it to the triangle it pops a messagebox("TRIANGLE!!!"). That would help me soo much! Thanks!
Re: Dynamically adding event args?
Hmm, that's not exactly a "Simple Example" :)
An Excellent example of how to add event handlers at runtime is available in the 101 VB.Net Examples at the top of this forum. Check out "Dynamic Control Creation"
Bill
Re: Dynamically adding event args?
Thanks, I'm checkin' out these examples and hopefully I can figure something out from them! THANKS SOO MUCH!!!
Mike
Re: Dynamically adding event args?
conipto is officially my hero!!! that worked great, you have no idea how greatful I am... YOU RULE!