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. Preventing multiple call to button's event handler

Preventing multiple call to button's event handler

Scheduled Pinned Locked Moved Visual Basic
questioncsscom
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.
  • K Offline
    K Offline
    Kapil Thakur
    wrote on last edited by
    #1

    hi, i have added a button in windows datagrid. it works fine when i load the grid first time and click the button. but if i reload the datagrid again on some event and i click the button, its click handler is called twice. if i again load the grid then the click handler is called thrice. how can i correct this ? i want to call the button's click handler only once like in normal application.

    Regards, Kapil Thakur (Where's there is Kapil , there is a way) - thakur.kapil@gmail.com

    D A 2 Replies Last reply
    0
    • K Kapil Thakur

      hi, i have added a button in windows datagrid. it works fine when i load the grid first time and click the button. but if i reload the datagrid again on some event and i click the button, its click handler is called twice. if i again load the grid then the click handler is called thrice. how can i correct this ? i want to call the button's click handler only once like in normal application.

      Regards, Kapil Thakur (Where's there is Kapil , there is a way) - thakur.kapil@gmail.com

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Somewhere in your code you used AddHandler to wire up the Click events of the button. Before you reload the data into the grid, use RemoveHandler to unwire those buttons before you destroy them.

      Dave Kreskowiak Microsoft MVP - Visual Basic

      1 Reply Last reply
      0
      • K Kapil Thakur

        hi, i have added a button in windows datagrid. it works fine when i load the grid first time and click the button. but if i reload the datagrid again on some event and i click the button, its click handler is called twice. if i again load the grid then the click handler is called thrice. how can i correct this ? i want to call the button's click handler only once like in normal application.

        Regards, Kapil Thakur (Where's there is Kapil , there is a way) - thakur.kapil@gmail.com

        A Offline
        A Offline
        Agus Budianto
        wrote on last edited by
        #3

        or you can use module level boolean variable to check wether the button is already clicked :)

        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