|
-
Feb 8th, 2012, 09:14 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] CheckBox Error
Code:
Private Sub CheckBox1_CheckChanged(sender As System.Object, e As System.EventArgs) Handles CheckBox1.CheckChanged
If TextBox1.Text = "Default" Then
MessageBox.Show("Default")
CheckBox1.Checked = False
Else
MsgBox("Not Default")
End If
End Sub
by default, the checkbox is not checked. now when i click the checkbox, I want it to do the above code.
if the box says "default", i want it to msgbox default, and then uncheck the check box. (it is automatically checked after i click it)
problem is, the msgbox pops up twice. any help.
-
Feb 8th, 2012, 09:28 PM
#2
Addicted Member
Re: CheckBox Error
That's because when CheckBox1.Checked = False i ran it activates the event CheckChanged again.
Try MouseClick Event..
Last edited by m.davide; Feb 8th, 2012 at 09:34 PM.
-
Feb 8th, 2012, 09:31 PM
#3
Re: CheckBox Error
If you only want to execute some code when the CheckBox is checked, shouldn't you have some code in their to test whether it is checked or unchecked? That event is raised in both cases, so if you want to differentiate between the two you must do so with your own code.
-
Feb 8th, 2012, 09:49 PM
#4
Thread Starter
Hyperactive Member
Re: CheckBox Error
Oh duh. Thanks, got it working! I must be sleepy if I didn't see that..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|