In this C# example, we’ll learn How to remove multiple checked items from CheckedListBox.
The C# Checked ListBox is simple list box with the combination of checks. It provides you the list and checks to mark them as you select the items. The user can select the single and multiple checks. According to the need, you can set the checks enabled and disabled.
You can create conditional statements on which C# Checked ListBox will become enabled and disabled. When professional programmers used Checked ListBox they will also use the Conditional Statements.
They make sure that checked boxes will become enabled only when user will fill up or proceed the above instructions. A live example of checkbox usage is the terms & condition form of any organization.
If you are getting started with YouTube they will be asked you to read their terms and checked in the last that you are agreed or not. If you will check the box only then you can process forward.
Same is the case will C# Checked ListBox, developers make the conditional check for inputs gained from C# Checked ListBox.
In the following code (Form_Load), you can be observed how we inserted the values inside C# Checked ListBox.
1 2 3 4 5 6 7 8 9 10 11 | private void Form1_Load(object sender, EventArgs e) { checkedListBox1.Items.Add("C#"); checkedListBox1.Items.Add("C++"); checkedListBox1.Items.Add("Python"); checkedListBox1.Items.Add("Java"); checkedListBox1.Items.Add("PHP"); checkedListBox1.Items.Add("ASP.NET"); } |
Remove Selected Items From CheckedListbox:
1 2 3 4 5 6 7 8 9 | private void button1_Click(object sender, EventArgs e) { foreach (string item in checkedListBox1.CheckedItems.OfType<string>().ToList()) { checkedListBox1.Items.Remove(item); } } |