private void CheckBoxCheckedChanged(object sender, EventArgs e) { CheckBox c = (CheckBox)sender; //Label myLabel; String str = null; if (c.Checked == true) { str = c.Text; gpBox[gpcount] = new GroupBox(); gpBox[gpcount].Name = "gpBox" + Convert.ToString(count); gpBox[gpcount].Text = str; gpBox[gpcount].Location = new Point(5, gpposition); gpBox[gpcount].AutoSize = true; this.Controls.Add(gpBox[gpcount]); aCommand3 = new OleDbCommand("select * from batch_tbl where batch_branch LIKE '" + str + "'", main_connection); aAdapter3 = new OleDbDataAdapter(aCommand3); ds3 = new DataSet(); aAdapter3.Fill(ds3, "app_info"); ds3.Tables[0].Constraints.Add("pk_bno", ds3.Tables[0].Columns[0], true); int batch_count = ds3.Tables[0].Rows.Count; batchCheckBox = new CheckBox[batch_count]; //filling the groupbox with batch code by generating dynamic checkboxes for (int j=0; j < batch_count; ++j) { batchCheckBox[j] = new CheckBox(); batchCheckBox[j].Name = "batch" + Convert.ToString(k); batchCheckBox[j].Text = ds3.Tables[0].Rows[j][1].ToString(); Console.WriteLine(batchCheckBox[j].Text); batchCheckBox[j].Location = new System.Drawing.Point(104 * position, 30); gpBox[gpcount].Controls.Add(batchCheckBox[j]); batchCheckBox[j].CheckStateChanged += new System.EventHandler(BatchBoxCheckedChanged); position++; count++; Console.WriteLine(batchCheckBox[j].Name); k++; } position = 1; gpposition += 100; } else { count--; this.Controls.RemoveByKey("lbl" + c.Name); this.Update(); } } int total_batch = 1; string[] batchname; private void BatchBoxCheckedChanged(object sender, EventArgs e) { CheckBox batchBox = (CheckBox)sender; //Here I want to store name of checkbox in array if (batchBox.Checked == true) { batchname = new String[total_batch]; total_batch++; } else { } }
BatchBoxCheckedChanged
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)