CheckedListBox in ASP.NET Using VB.NET

In this article we demonstrate on what is CheckedListBox control,it's notable properties in different sections and how you can use this control.
  • 3001
Download Files:
 

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 1.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

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.