Results 1 to 6 of 6

Thread: [Resolved]Dynamically adding event args?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Location
    Warren, MI
    Posts
    209

    [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
    Last edited by spelltwister; Nov 16th, 2005 at 08:15 PM.

  2. #2
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    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
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Location
    Warren, MI
    Posts
    209

    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!

  4. #4
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    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
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Location
    Warren, MI
    Posts
    209

    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

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Location
    Warren, MI
    Posts
    209

    Re: Dynamically adding event args?

    conipto is officially my hero!!! that worked great, you have no idea how greatful I am... YOU RULE!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width