Hi all,
I have two problems
1. I have a comma separated string values. I want to load them all into checkedlistbox as items.....HOW?
2. how do I get the itemindex of checkedlistbox, passing the text?
regards and thanks
Jeet
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Niradhip ChakrabortyPosted May 22, 2009, 3:43 AM
Say your strAlldata with comma separater having all the values and chkKiosks is the id for checkbox. Now split the comma separated string and put it in array.
loop through all the array element and put it into checkbox. I have used blnfound
based on requirement you can check or uncheck the checkBox.
Array arrCheckedKiosk;
arrKioskName = strAlldata.Split(',');
bool blnFound;
blnFound = false;
if (arrKioskName != null)
{
foreach (object obj in arrKioskName)
{
chkKiosks.Items.Add(obj.ToString(), blnFound);
}
}
You can get the itemIndex like below.
for (int i = 0; i < chkKiosks.Length; i++)
{
string x = chkKiosks.GetValue(i).ToString()
}