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.
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 Properties
|It is used to get the default size of the checkbox.
|The 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.
|It is used to set the checkmark’s alignment, such as horizontal or vertical on the checkbox.
|The Appearance property is used to display the appearance of a checkbox control by setting a value.
|The CheckState property is used to verify whether the checkbox status is checked in the window form.
|The ThreeState property is used to check whether the control allows one to set three check positions instead of two by setting values.
|It is used to obtain or set the flat appearance of a checkbox.
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 Methods
|The OnClick method is used to fetch the Click event in the CheckBox control.
|It is used to call the CheckStateChanged event in the CheckBox control.
|The ToString method is used to return the current string of the CheckBox control.
|When the Checked property is changed in the CheckBox control, the OnCheckedChanged events occur.
|It is used when it receives the OnMouseUp event in the CheckBox control.
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 Event
|The CheckedChanged event is found when the value of the checked property is changed to CheckBox.
|It occurs when the user performs a double click on the CheckBox control.
|It occurs when the value of the CheckState property changes to the CheckBox control.
|It occurs when the property of the Appearance is changed to the CheckBox control.
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"
If CheckBox2.Checked = True Then
'fruit = CheckBox2.Text
prog = prog & "," & " VB.net"
If CheckBox3.Checked = True Then
prog = prog & "," & " Java"
If CheckBox4.Checked = True Then
prog = prog & "," & " PHP"
If CheckBox5.Checked = True Then
If CheckBox6.Checked = True Then
prog = prog & "," & " C/C++"
If CheckBox7.Checked = True Then
prog = prog & "," & " C#"
If CheckBox8.Checked = True Then
prog = prog & "," & " ASP.net"
If prog.Length <> 0 Then
MsgBox(" Selected Programming languages: " & prog)
CheckBox1.ThreeState = True
Now select the Most Programming Language Used by clicking on the items.
Now click on the Submit button, it displays the following output on your screen.
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.
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.