hi Mun Fong,
just need slight change to your code ..check the checkstate so that it
bypass the checked = false
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
if checkbox1.checkState = checkstate.checked then
If (Condition1=False) then
If (CheckBox1.Checked)Then
MsgBox ("Condition 1 False cannot proceed!")
CheckBox1.Checked = False
End If
Else
'Do my thing
End If
end if
End Sub
Albert
"Woo Mun Foong" wrote:
> I have a checkbox, when enable, allows me to proceed with what I like to do.
> However, I need to check a certain conditions before I allow the checked box
> to be checked, if condition is not fullfill I need to cancel the Checked
> State.
> I captured the Mouse Click event inside CheckedChanged and
> CheckedStateChanged Events but it goes into infinite loops.
>
> I am using VB.NET 2003 and .NET 1.1
>
> Briefly, my code is as follows:-
>
> Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, _
> ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
> If (Condition1=False) then
> If (CheckBox1.Checked)Then
> MsgBox ("Condition 1 False cannot proceed!")
> CheckBox1.Checked = False
> End If
> Else
> 'Do my thing
> End If
> End Sub
>
>
> The code doesn't let me unchecked the checkbox. Is there any Cancel method
> for Checkbox Events?
|