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!

please help me!

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

    I have a check box and a button and a lable that I want they do one thing. how can i write only one code for them.. for example i want if i click on lable the check box set to true and next time set to false..exactly such as when i click check box.. please help me..

    N 1 Reply Last reply
    0
    • X xstoneheartx

      I have a check box and a button and a lable that I want they do one thing. how can i write only one code for them.. for example i want if i click on lable the check box set to true and next time set to false..exactly such as when i click check box.. please help me..

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

      if you want a click event to occur on more than one object, and it to perform the same code for each event, you must include an array handle. the following is a sample of how to have a click event for a checkbox,button, and label all do the same thing; change the state of the checkbox.

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

      note the end of the sub declaration line, after handles ("Handles Button1.click, label1.click") you can add more events for objects here for this code to be called once that event occurs. edit: notice you dont have to include any event handler for the actual checkbox.checkedchange (or click) methods ------------------------ Jordan. III

      X 1 Reply Last reply
      0
      • N Nadroj

        if you want a click event to occur on more than one object, and it to perform the same code for each event, you must include an array handle. the following is a sample of how to have a click event for a checkbox,button, and label all do the same thing; change the state of the checkbox.

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

        note the end of the sub declaration line, after handles ("Handles Button1.click, label1.click") you can add more events for objects here for this code to be called once that event occurs. edit: notice you dont have to include any event handler for the actual checkbox.checkedchange (or click) methods ------------------------ Jordan. III

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

        Thanx Jordan But if i want to have some code in checkbox_chackedchange ...what should I do? for example.. I have a 2 labels and a check box.. I want if Iclick on checkbox a change a setting, and for that 2 labels too if I click on them that setting get changed...it means the code of chck and labels are the same help me Please again

        N 1 Reply Last reply
        0
        • X xstoneheartx

          Thanx Jordan But if i want to have some code in checkbox_chackedchange ...what should I do? for example.. I have a 2 labels and a check box.. I want if Iclick on checkbox a change a setting, and for that 2 labels too if I click on them that setting get changed...it means the code of chck and labels are the same help me Please again

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

          so you want the code to occur under the click events of the labels AND the checkbox..? ok here you go Private Sub MyHugeEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click, Label1.Click, CheckBox1.Click If CheckBox1.Checked = True Then CheckBox1.Checked = False Else CheckBox1.Checked = True End If End SubNOTE: you MUST set the AutoCheck property of the checkbox to FALSE. ------------------------ 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