catalin ilie

catalin ilie

  • NA
  • 1
  • 9.3k

Checkboxlist index issue

Dec 8 2010 3:36 AM
Hello there. i want to make an application, i use a checkboxlist, and i want to retain in an array checked or unchecked indexes like this: for unchecked items, the array location should be a 0, and for checked items, the array location should be 1.
i tried like this:

[code]

private void checkboxlist1_SelectedIndexChanged(object sender, EventArgs e)
{
     int[] v=new int[6];
     for(int i=0;i<6;i++)
if(checkboxlist1.getitemchecked(i))
v[i]=1;
else
v[i]=0;
  string w=v.ToString();

}

[/code]


and then , the result is wrong. for example, if i check the first three items, the result will be 110000. it seems it's a step behind or something. should i use itemcheck event instead of selectedindexchanged, or both, or what? thank you


Answers (4)