Please help me! _event handeling
-
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
-
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
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
-
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
Tanx nice solution i can't remember that what did i do that mades overflow error
-
Tanx nice solution i can't remember that what did i do that mades overflow error
-
check back to my other post, it is the solution to your problem. it handles the event for all 3 objects. ------------------------ Jordan. III
Thanx for your answer
-
Thanx for your answer
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