private void button1_Click(object sender, EventArgs e)
{
string s = "";
foreach(Control c in this.Controls)
{
if (c is CheckBox)
{
CheckBox b = (CheckBox) c;
if (b.Checked) {
//s = b.Text + s; // if u want to add spaces or seperation between ur selection u can add like this
s = b.Text + "," + s;
}
}
}
MessageBox.Show(s); //if u want to save in database u can directly save string value s
cn.Open();
SqlCommand cmd = new SqlCommand("insert into mcombo values('" + s + "')", cn);
cmd.ExecuteNonQuery();
cn.Close();
}
//videoor go through this youtube
videohttps: //www.youtube.com/watch?v=hJ5m-PH6td4Go through this Youtube video.This code snippet for Saving Multiple checkboxes in single column database.