I have 30 checkboxes (cb1, cb2,... ,cb30) that I need to be checked programmatically based on a variable value. So, when the var value is 12, I need the checkbox1 to checkbox12 to be .checked = true;
I really have no Idea how to get it work Please help
Thank you
Edit: I tried aghilpro's suggestion but I got errors:
reader1.Read();
if (reader1.IsDBNull(0))
{
label5.Text = "Nothing yet";
}
else
{
label5.Text = reader1.GetString(0).ToString() + " Times";
{
for (int i = 0; i < reader1.GetInt32(0); i++)
{
Controls["checkBox" + i.ToString()].Checked = True;
}
}
}
koneksi.Close();
Here's the output:
Error 1 'System.Windows.Forms.Control' does not contain a definition for 'Checked' and no extension method 'Checked' accepting a first argument of type 'System.Windows.Forms.Control' could be found (are you missing a using directive or an assembly reference?)