I want to use a CheckedListBox in an application where each item in the ListBox is the name of a folder on my hard drive and for the purpose of reading and writing text files to and from each of these folders I want to ensure that multiple item (a folder) can be selected at any time in the CheckedListBox
Thanks for reading :-)
private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
{
CheckedListBox.CheckedIndexCollection checkedIndices = checkedListBox1.CheckedIndices;
if (checkedIndices.Count > 0)
{
if (checkedIndices[0] != e.Index)
{
checkedListBox1.ItemCheck -= checkedListBox1_ItemCheck;
checkedListBox1.SetItemChecked(checkedIndices[0], true);
checkedListBox1.ItemCheck += checkedListBox1_ItemCheck;
}
else
{
checkedListBox1.SetSelected(e.Index, false);
}
}
}
I can select multiple files but my main question is How to select text files from the directory..
How can I achieve this via code in C#?