Net-informations.com
SiteMap  | About    

C# Checked ListBox Control

The CheckedListBox control gives you all the capability of a list box and also allows you to display a check mark next to the items in the list box.

C# checkedlistbox

The user can place a check mark by one or more items and the checked items can be navigated with the CheckedListBox.CheckedItemCollection and CheckedListBox.CheckedIndexCollection. To add objects to the list at run time, assign an array of object references with the AddRange method. The list then displays the default string value for each object.

  Dim days As String() =  {"Sunday", "Monday", "Tuesday"};
  checkedListBox1.Items.AddRange(days);

You can add individual items to the list with the Add method. The CheckedListBox object supports three states through the CheckState enumeration: Checked, Indeterminate, and Unchecked.

  checkedListBox1.Items.Add("Sunday", CheckState.Checked);
  checkedListBox1.Items.Add("Monday", CheckState.Unchecked);
  checkedListBox1.Items.Add("Tuesday", CheckState.Indeterminate);



using System;
using System.Drawing;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            checkedListBox1.Items.Add("Sunday", CheckState.Checked);
            checkedListBox1.Items.Add("Monday", CheckState.Unchecked);
            checkedListBox1.Items.Add("Tuesday", CheckState.Indeterminate);
            checkedListBox1.Items.Add("Wednesday", CheckState.Checked);
            checkedListBox1.Items.Add("Thursday", CheckState.Unchecked);
            checkedListBox1.Items.Add("Friday", CheckState.Indeterminate);
            checkedListBox1.Items.Add("Saturday", CheckState.Indeterminate);
        }
    }
}




net-informations.com (C) 2016    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.