How to uncheck items from CheckListBox


If user have selected different number of items in CheckListBox; and if you want to reset the CheckListBox again; then you can achieve that from here.

How to Uncheck Checked Items from CheckListBox



CheckedListBox provides you the list of checkbox items so that user can select more than one options. But if you want to reset the CheckListBox you can do it.

Code Explained:



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace dns_uncheced_CheckList
{
public partial class Form1 : Form
{
IEnumerator enumCountry; //Enumerator declared
public Form1()
{
InitializeComponent();
}

private void btnReset_Click(object sender, EventArgs e)
{
//Getting checked items from the checkListBox into enumerator
enumCountry = checkedListBoxCountry.CheckedIndices.GetEnumerator();

int iCurrentCountry;

while (enumCountry.MoveNext() != false)
{
iCurrentCountry = (int)enumCountry.Current;
checkedListBoxCountry.SetItemChecked(iCurrentCountry, false);
lblMessage.Text = "MESSAGE: All checked items unchecked!";
}
}

}
}


Attachments

  • uncheck_CheckListBox (37632-11225-dns_uncheced_CheckList.rar)
  • Comments

    Author: MeherSudha20 Aug 2011 Member Level: Bronze   Points : 0

    this is help full to beginners



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: