CheckBox Control in VB.net – Properties, Methods and Events

What is CheckBox Control in VB.net?

The CheckBox Control in VB.net is a control that lets the user select or deselect alternatives from the list of choices.

A checkmark or tick will show up on the Windows form when a checkbox is chosen.

In this lesson, we shall learn How To Write a Program for CheckBox in VB.net.

Let’s create CheckBoxes in VB.net by dragging CheckBox controls from the Toolbox and dropping them on the form.

CheckBox Control in VB.net Tutorial
CheckBox Control Tutorial

The three possible states for the CheckBox Control in VB.net are checked, unchecked, and indeterminate.

The checkbox is grayed out in the uncertain condition.

The check box’s Three State property is set to True to enable the indeterminate state.

Properties of CheckBox Control in VB.net

The following given below are some commonly used Properties of the CheckBox Control in VB.net.

#CheckBox Control in VB.net PropertiesDescription
1.DefaultIt is used to get the default size of the checkbox.
2.AutoCheckThe AutoCheck property is used to check whether the checked value or appearance of control can be automatically changed when the user clicked on the CheckBox control.
3.CheckAlignIt is used to set the checkmark’s alignment, such as horizontal or vertical on the checkbox.
4.AppearanceThe Appearance property is used to display the appearance of a checkbox control by setting a value.
5.CheckStateThe CheckState property is used to verify whether the checkbox status is checked in the window form.
6.ThreeStateThe ThreeState property is used to check whether the control allows one to set three check positions instead of two by setting values.
7.FlatStyleIt is used to obtain or set the flat appearance of a checkbox.
Properties and Description of CheckBox in VB.net

Methods of CheckBox Control in VB.net

The following given below are some commonly used Methods of CheckBox Control in VB.net.

#CheckBox Control in VB.net MethodsDescription
1.OnClickThe OnClick method is used to fetch the Click event in the CheckBox control.
2.OnCheckStateChangedIt is used to call the CheckStateChanged event in the CheckBox control.
3.ToStringThe ToString method is used to return the current string of the CheckBox control.
4.OnCheckedChangedWhen the Checked property is changed in the CheckBox control, the OnCheckedChanged events occur.
5.OnMouseUpIt is used when it receives the OnMouseUp event in the CheckBox control.
Methods and Description of CheckBox in VB.net

Events of CheckBox Control in VB.net

The following given below are some commonly used Events of the CheckBox Control in VB.net.

#CheckBox Control in VB.net EventDescription
1.CheckedChangedThe CheckedChanged event is found when the value of the checked property is changed to CheckBox.
2.DoubleClickIt occurs when the user performs a double click on the CheckBox control.
3.CheckStateChangedIt occurs when the value of the CheckState property changes to the CheckBox control.
4.AppearanceChangedIt occurs when the property of the Appearance is changed to the CheckBox control.
Events and Description of CheckBox in VB.net

CheckBox Windows Form

Let’s create a program to understand the uses of CheckBox control in VB.net Windows Form.

Public Class Form1
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim prog As String
        prog = " "
        If CheckBox1.Checked = True Then
            prog = "Python"
        End If
        If CheckBox2.Checked = True Then
            'fruit = CheckBox2.Text  
            prog = prog & "," & " VB.net"
        End If
        If CheckBox3.Checked = True Then
            prog = prog & "," & " Java"
        End If
        If CheckBox4.Checked = True Then
            prog = prog & "," & " PHP"
        End If
        If CheckBox5.Checked = True Then
            prog = prog & "," & " JavaScript"
        End If
        If CheckBox6.Checked = True Then
            prog = prog & "," & " C/C++"
        End If
        If CheckBox7.Checked = True Then
            prog = prog & "," & " C#"
        End If
        If CheckBox8.Checked = True Then
            prog = prog & "," & " ASP.net"
        End If
        If prog.Length <> 0 Then
            MsgBox(" Selected Programming languages: " & prog)
        End If
        CheckBox1.ThreeState = True
    End Sub
End Class

Program Output:

CheckBox Control in VB.net Form Output
CheckBox Control Form Output

Now select the Most Programming Language Used by clicking on the items.

CheckBox Control in VB.net Form Selecting Items
CheckBox Control Form Selecting Items

Now click on the Submit button, it displays the following output on your screen.

CheckBox Control in VB.net Form Display Message Box
CheckBox Control Form Display Message Box

Difference Between Option Button and CheckBox in VB.net

The Difference Between Option Button and CheckBox in VB.net, You can choose more than one item in the Check box.

If you click a radio button, a small dot appears in the center of the circle.

if you click a check box, a small checkmark appears in the center of the square.

If you click a different choice, the dot will move to the center of the new circle that you have selected in the radio button.

if you click a check box, another check appears in the new box, and the frog will appear.

Summary

In this article we have discussed how to create a program for CheckBox in VB.net using Microsoft Visual Studio, we have learned how to use and manage the different Properties, Methods, and Events of the CheckBox in VB.net.


Common use cases for CheckBox Control

CheckBox Control is a standard Windows Forms element that appears in most VB.NET desktop apps. Typical uses:

  • User input capture. Bind to viewmodel properties for two-way data flow.
  • Display of collections. Populate with in-memory lists, database result sets, or file system contents.
  • Event-driven behaviors. Wire up Click, SelectedIndexChanged, or KeyDown handlers for interactivity.
  • Data validation. Use Validating and Validated events to enforce input rules before persistence.
  • Custom styling. Override OnPaint or use owner-draw modes for branded looks.

Wiring CheckBox Control into your form

The standard pattern for adding CheckBox Control at runtime looks like this:

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ' Configure the control's initial state
        Me.Text = "CheckBox Control Example"
        ' Attach event handlers programmatically
        AddHandler MyControl.Click, AddressOf MyControl_Click
    End Sub

    Private Sub MyControl_Click(sender As Object, e As EventArgs)
        ' React to user interaction here
        MessageBox.Show("Control was clicked")
    End Sub

End Class

Best practices for CheckBox Control

  • Name controls consistently. Use a Hungarian-style prefix (btn, txt, lbl, lst) so the codebehind reads cleanly.
  • Group related controls in a Panel or GroupBox. Improves layout maintainability and keyboard tab order.
  • Set TabIndex explicitly. Do not rely on design-time order; keyboard navigation matters for accessibility.
  • Use data binding when possible. Avoid manual .Text = someValue assignments scattered across the codebehind.
  • Handle Dispose(). Custom controls that hold GDI resources must implement IDisposable properly.

Troubleshooting CheckBox Control

  • Event handler does not fire. Confirm the Handles clause matches the exact control name, or that AddHandler was called.
  • Design-time appearance differs from runtime. This usually means custom OnPaint code is not respecting DesignMode. Check with Me.DesignMode.
  • Control flashes or flickers on redraw. Enable double-buffering by setting DoubleBuffered = True on the parent form.
  • Cross-thread exceptions. UI updates from background threads must use Control.Invoke() or the BackgroundWorker.ReportProgress pattern.

Frequently Asked Questions

What is the CheckBox Control in VB.NET used for?
The CheckBox Control is a Windows Forms control that captures user input or displays data in a familiar UI element. It sits in the Toolbox in Visual Studio and can also be created at runtime through code.
How do I add the CheckBox Control to my form?
Drag it from the Visual Studio Toolbox onto the form designer, or instantiate it in code with New and add it to Me.Controls. Both approaches produce identical runtime behavior.
What are the most-used CheckBox Control properties?
Name, Text, Location, Size, and Enabled are set on almost every instance. Font, ForeColor, and BackColor are common for styling. Anchor and Dock control how the control resizes with the form.
How do I handle CheckBox Control events?
Double-click the control in the form designer to auto-generate a default event handler. Or wire up manually with AddHandler MyControl.EventName, AddressOf HandlerMethod inside Form_Load.
Can I use the CheckBox Control in WPF or MAUI?
No. Windows Forms controls are specific to WinForms. WPF has its own control hierarchy under System.Windows.Controls, and MAUI uses cross-platform equivalents. Use the framework-appropriate control instead.
Angel Jude Suarez


Full-Stack Developer at PIES IT Solution

Focuses on Python development, machine learning, and AI integration. Has built production AI systems including OpenAI Whisper integration for medical transcription and GPT-4o-powered diagnosis assistance. Strong background in pandas, scikit-learn, and TensorFlow.

Expertise: Python · PHP · Java · VB.NET · ASP.NET · Machine Learning · AI Integration · OpenCV · Django · CodeIgniter
 · View all posts by Angel Jude Suarez →

Leave a Comment