CheckedListBox is a combination of a ListBox and a CheckBox. CheckedListBox can have items added using the String Collection Editor or their items can add dynamically from a collection at run time, using the Items property.

Drag and drop a CheckedListBox from toolbox on the window form

CheckedListBox Control in VB.Net

CheckOnClick property should be true in CheckedListBox so that when you click on the Text then references checkbox is checked.

Code:

Public Class mindstick
 
    Private Sub CheckedListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckedListBox1.SelectedIndexChanged
 
        Label2.Text = "You selected  " + CheckedListBox1.SelectedItem.ToString()
    End Sub
    Private Sub mindstick_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' Here items is added in the CheckedListBox1
        CheckedListBox1.Items.Add("C#")
        CheckedListBox1.Items.Add("J#")
        CheckedListBox1.Items.Add("VB")
    End Sub
End Class

In above code Item is added dynamically so all Item in CheckedListBox1  will show at run time.

Run the project

CheckedListBox Control in VB.Net

When you select the given option then SelectedIndexChanged event will fire and selected value will show in the Label.

CheckedListBox Control in VB.Net

Change CheckedListBox Appearance

Set the forecolor of checkedListBox on FormLoad event as

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        CheckedListBox1.ForeColor = Color.Green
End Sub

ForeColor of CheckedListBox will be changed at run time.

Output:

CheckedListBox Control in VB.Net

  Modified On Mar-22-2018 07:19:23 AM

Leave Comment