ARTICLE

How to work with CheckedListBox in VB.NET

Posted by Dea Saddler Articles | ASP.NET using VB.NET April 07, 2011
In this article we demonstrate on what is CheckedListBox control,it's notable properties in different sections and how you can use this control.
Download Files:
 
Reader Level:

A visual basic CheclListBox control is a combination of a ListBox and a CheckBox. It displays a ListBox with a CheckBox towards its left. The CheckListBox class is derived from the ListBox class and is based on that class. Since the CheckListBox is derived from ListBox it shares all the members of ListBox. CheckedListBox can have items added using the string collection editor or items can add dynamically from a collection at RunTime, Using the Item property.


Notable Properties of CheckListBox

  • In Apearence:-
    The notable property in the Appearence Section of the properties window is the ThreeDCheckBoxes property which is set to False by default. Setting it to true makes the CheckListBox to be displayed in Flat or Normal style. 
  • In Behaviour:-
    The notable property in the Behaviour section is the CheckOnClick Property which is set to false by default. When set to false it means that to check or uncheck an item in the CheckedListBox you need to double click the item. Setting it to true makes an item in the CheckedListBox to be checked or unchecked with a single click. 
  • In Data:-
    The notable property in Data section is the Items property with which you add items to the CheckedListBox.

How to use CheckedListBox:-
  • Simply Open a new project. 
  • Drag a CheckedListBox control on form. Form will look like below.

    CheckedListBox.gif
     
  • Write the below code on Form.

       Private Sub CheckedListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
           
    CheckedListBox1.SelectedIndexChanged
            Label1.Text = "You selected  " + CheckedListBox1.SelectedItem.ToString()
        End Sub
        Private Sub Form1_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

Output:-

CheckedListBox2.gif

CheckedListBox3.gif 

Login to add your contents and source code to this article
share this article :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Team Foundation Server Hosting
Become a Sponsor