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. C#
  4. Event handler for check box

Event handler for check box

Scheduled Pinned Locked Moved C#
csharp
2 Posts 2 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.
  • S Offline
    S Offline
    sirisha guttikonda
    wrote on last edited by
    #1

    Hi all I have 20 check boxes in my page and i need to fire the checkbox checked event for all check boxes. Instead of writing the checked event for each and every checkbox is there any way to fire the checked event with only one function.i need to get check box id if it is checked. I'm doing in C#.Net web application Thank you.

    siri

    E 1 Reply Last reply
    0
    • S sirisha guttikonda

      Hi all I have 20 check boxes in my page and i need to fire the checkbox checked event for all check boxes. Instead of writing the checked event for each and every checkbox is there any way to fire the checked event with only one function.i need to get check box id if it is checked. I'm doing in C#.Net web application Thank you.

      siri

      E Offline
      E Offline
      Eslam Afifi
      wrote on last edited by
      #2

      Write something like this in the constructor or the form's Load event or whatever.

      checkBox1.CheckedChanged += checkBox_CheckedChanged // the checkBox_CheckedChanged function
      //now handles the CheckedChanged event of checkBox1
      checkBox2.CheckedChanged += checkBox_CheckedChanged
      checkBox3.CheckedChanged += checkBox_CheckedChanged
      //...

      Or you can simply set the CheckedChanged handler function from the Properties window (the Events section) for the checkboxes. And to know which fired the event, it's the sender argument of the handler.

      CheckBox Sender = (CheckBox)sender; //unbox to checkbox

      Eslam Afifi

      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