Hi, I am new to this. i would like to pass over checked values from form1 to form2 however i am currently using the dynamic checkbox, thus the output i would like use for another sql query in form2.
Here is my code:
- private void populateSalesCategory()
- {
- con.Connect();
- string selectQuery = "SELECT * FROM SalesCategory";
- using (SqlDataAdapter sda = new SqlDataAdapter(selectQuery, con.conn))
- {
-
- DataTable scdt = new DataTable();
- sda.Fill(scdt);
-
- string sc = "";
- foreach (DataRow row in scdt.Rows)
- {
- CheckBox chk = new CheckBox();
- chk.Width = 100;
- chk.Text = row["CategoryName"].ToString();
- chk.CheckedChanged += new EventHandler(changecheck);
- salesCategoryPanel.Controls.Add(chk);
- }
- }
- }
- private void changecheck(object sender, EventArgs e)
- {
- CheckBox chk = sender as CheckBox;
- if (chk.Checked)
- {
- MessageBox.Show(chk.Text);
- }
- }
Thanks a lot.