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. Please help me! _event handeling

Please help me! _event handeling

Scheduled Pinned Locked Moved Visual Basic
helpquestion
6 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.
  • X Offline
    X Offline
    xstoneheartx
    wrote on last edited by
    #1

    I have a 2 labels and a check box.. I want if I click on checkbox change a setting, and for that 2 labels too ,if I click on them that setting maust change...it means the code of check and labels are the same so how can I write one code for them 3.. (i have recive a reply "please help me " ..good but not complete) help me Please again

    D 1 Reply Last reply
    0
    • X xstoneheartx

      I have a 2 labels and a check box.. I want if I click on checkbox change a setting, and for that 2 labels too ,if I click on them that setting maust change...it means the code of check and labels are the same so how can I write one code for them 3.. (i have recive a reply "please help me " ..good but not complete) help me Please again

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

      Yes. The reply you got before was complete! If there is something missing, it's because the requirements you gave us are not complete.

      Private Sub Label1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click, Label2.Click
          If CheckBox1.Checked = True Then
              CheckBox1.Checked = False
          Else
              CheckBox1.Checked = True
          End If
      End Sub
      

      Note: You don't need code for the CheckBox itself to change it's state. The CheckBox will automatically handle that itself. UPDATE: I see from you other post that your looking to put code in the CheckChanged event of the CheckBox. You didn't mention what you wanted to put in your event handler, so, adding to the code above...

      Private Sub CheckBox1\_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
          MsgBox("Check Changed!")
      End Sub
      

      And, no, it's NOT a good idea for one function to handle both the Label Click's and the Check Changed events. Clicking on the Labels will generate a Click event, which will call the Click handler above. If you change the status of the CheckBox, it will generate a CheckChanged event and will call your Click handler AGAIN. RageInTheMachine9532

      X 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Yes. The reply you got before was complete! If there is something missing, it's because the requirements you gave us are not complete.

        Private Sub Label1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click, Label2.Click
            If CheckBox1.Checked = True Then
                CheckBox1.Checked = False
            Else
                CheckBox1.Checked = True
            End If
        End Sub
        

        Note: You don't need code for the CheckBox itself to change it's state. The CheckBox will automatically handle that itself. UPDATE: I see from you other post that your looking to put code in the CheckChanged event of the CheckBox. You didn't mention what you wanted to put in your event handler, so, adding to the code above...

        Private Sub CheckBox1\_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
            MsgBox("Check Changed!")
        End Sub
        

        And, no, it's NOT a good idea for one function to handle both the Label Click's and the Check Changed events. Clicking on the Labels will generate a Click event, which will call the Click handler above. If you change the status of the CheckBox, it will generate a CheckChanged event and will call your Click handler AGAIN. RageInTheMachine9532

        X Offline
        X Offline
        xstoneheartx
        wrote on last edited by
        #3

        Tanx nice solution i can't remember that what did i do that mades overflow error

        N 1 Reply Last reply
        0
        • X xstoneheartx

          Tanx nice solution i can't remember that what did i do that mades overflow error

          N Offline
          N Offline
          Nadroj
          wrote on last edited by
          #4

          check back to my other post, it is the solution to your problem. it handles the event for all 3 objects. ------------------------ Jordan. III

          X 1 Reply Last reply
          0
          • N Nadroj

            check back to my other post, it is the solution to your problem. it handles the event for all 3 objects. ------------------------ Jordan. III

            X Offline
            X Offline
            xstoneheartx
            wrote on last edited by
            #5

            Thanx for your answer

            N 1 Reply Last reply
            0
            • X xstoneheartx

              Thanx for your answer

              N Offline
              N Offline
              Nadroj
              wrote on last edited by
              #6

              let me know how it goes. the sub procedure i wrote in reply to my 1st original post will do what you want. it handles the 3 objects' click event, chaning the state of chk box. then right the code in the chkbox's checkedchanged method ------------------------ Jordan. III

              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