please help me!
-
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..
-
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..
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
-
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
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
-
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
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 Sub
NOTE: you MUST set the AutoCheck property of the checkbox to FALSE. ------------------------ Jordan. III