I can get close, but what you are saying is to:
Check blah amount of CheckBoxes in CheckBoxList foo
Code:
//The CheckBoxList name is boxes
int CA = Convert.ToInt32(CheckAmount.Text);
Random rng = new Random();
int x = 0;
for (int y = CA; y != 0; y--)
foreach (CheckBox i in boxes.Controls)
{
x = rng.Next(1, boxes.Length + 1); //have to add 1 or it will never pick the last box
if(boxes[boxes.Controls.IndexOf(i)] == x - 1)
{
i.Checked = true;
y--;
}
else
{
continue;
}
}
What this does is it looks through all of the checkboxes, and randomly selects blah checkboxes from boxes and checks them. blah is CA in your code.
Hope it helps!
Techcraft7