Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27077

VS 2008 [RESOLVED] Checkbox CheckState problem

$
0
0
Hi, I have a problem with some checkboxes. I have a form with two checkboxes and a textbox. When the checkbox 1 is checked, then the checkbox 2 should be unchecked. Also, if the checkbox 2 is unchecked, the textbox should be disabled.

The checkbox1 only unchecks the checkbox2, but the textbox is not disabled.

This is my code:

Code:

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged

        If CheckBox1.CheckState = CheckState.Checked Then

            CheckBox2.Checked = False
            CheckBox2.Enabled = False

        Else

            CheckBox2.Enabled = True

        End If
    End Sub

    Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged

        If CheckBox2.CheckState = CheckState.Unchecked Then

            TextBox1.Enabled = False

        Else

            TextBox1.Enabled = True
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        CheckBox1.Checked = True

    End Sub

The checkbox 1 is checked when when I start the application, the checkbox2 is unchecked, but the textbox is still enabled.

Which part of code am I missing?

Thanks in advance.

Viewing all articles
Browse latest Browse all 27077

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>