CheckedListBox Control for VB.net

Source: Internet
Author: User
Tags integer

A CheckedListBox (check list box) control can be said to be a derived control of a ListBox control, so many of the methods and properties of the ListBox control are inherited, and the icons in the Toolbox for CheckedListBox controls are as shown in the figure:

1.CheckedListBox Double_click Event
Like a list box, when a check list box appears as part of a dialog box, it is recommended that you add a button and use it with the list box. The Click event procedure for a button should use the options for the list box to perform an application-appropriate operation.
Double-clicking an item in the list and selecting the item first and then clicking the button have the same effect. To do this, you should call the button's click procedure during the DoubleClick procedure for the ListBox control:

Public Sub Listbox1_doubleclick (ByVal sender as Object,_
                   ByVal e as System.EventArgs) Handles listbox1.doubleclick< C3/>button1_click (sender,e) End
Sub is changed to: public
Sub Checkedlistbox1_doubleclick (ByVal sender as Object,_
                   ByVal e As System.EventArgs) Handles Listbox1.doubleclick
     button1_click (sender,e) End
Sub

2. Add Project at design time
You can also add items to a list at design time by setting the Items property of the CheckedListBox Control Properties window. When the Items property option is selected and clicked, the String Collection Editor pops up, entering the list item and pressing ENTER to wrap the line. Items can only be added at the end of the list. So, if you want to sort the list alphabetically, you should set the sorted property to True.

3. Operations on the project at run time
There are two ways to add items to a check list box
CHECKEDLISTBOXNAME.ITEMS.ADD (item as object,ischecked as Boolean)
Checkedlistboxname.insertitem (index as integer,item as Object)
The first method allows you to add an item to the check list box that identifies whether it is selected or not, and the second method to add items to the specified location. For example, add the following two items to the Check list box:
CHECKEDLISTBOX1.ITEMS.ADD ("DD", True)
Checkedlistbox1.insertitem (2, "KK")
To set the Checked property for a project, you can use the following statement:
Checkedlistbox.setitemchecked (index as integer,value as Boolean)
You can set the checked property of the KK project to true:
checkedlistbox1.setitemchecked (2,true) ' assumes that the index property of the KK project is 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.