Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How associate different event handler at runtime

How associate different event handler at runtime

Scheduled Pinned Locked Moved Visual Basic
data-structuresquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Amer Rehman 0
    wrote on last edited by
    #1

    Hi Can anybody tell me how can I associate different event handlers for an array of controls that I have created dynamically. Suppose I create ten buttons at runtime. I want that every button perform differnt action e.g. give a message of such type. "You clicked" & (Button.Name) How this can be done. Thanks

    reman

    K L 2 Replies Last reply
    0
    • A Amer Rehman 0

      Hi Can anybody tell me how can I associate different event handlers for an array of controls that I have created dynamically. Suppose I create ten buttons at runtime. I want that every button perform differnt action e.g. give a message of such type. "You clicked" & (Button.Name) How this can be done. Thanks

      reman

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      If you are using vb.net you need to use addhandler: Associates an event with an event handler at run time. AddHandler event, AddressOf eventhandler Hope that helps. Ben

      1 Reply Last reply
      0
      • A Amer Rehman 0

        Hi Can anybody tell me how can I associate different event handlers for an array of controls that I have created dynamically. Suppose I create ten buttons at runtime. I want that every button perform differnt action e.g. give a message of such type. "You clicked" & (Button.Name) How this can be done. Thanks

        reman

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Adding to what kubben said, you can use the same handler for all buttons, then inside that handler use the first argument "sender", cast it to Button and you can read the button's name, or whatever you want to access. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups