Hi,
I am creating dynamic checkboxes which should have an eventhandler attached to the submitButton. What I mean is while I’m changing state (check / uncheck) nothing should be happening but when I press the submitButton it should read all the checkboxes state and text.
Thx.
I am creating dynamic checkboxes which should have an eventhandler attached to the submitButton. What I mean is while I’m changing state (check / uncheck) nothing should be happening but when I press the submitButton it should read all the checkboxes state and text.
Thx.
Code:
SimpleButton submitButton = new SimpleButton();
submitButton.Location = new System.Drawing.Point(292, (29 + countMachines * 21) + 181);
submitButton.Name = "submitButton";
submitButton.Size = new System.Drawing.Size(78, 23);
submitButton.TabIndex = 0;
submitButton.Text = "Submit";
machineGroupControl.Controls.Add(submitButton);
submitButton.Click += new System.EventHandler(submitButton_click);
CheckBox[] dynamicMachineCheckbox = new CheckBox[countMachines];
for (int x = 0; x < countMachines; x++)
{
for (countLines = 0; countLines < this.maintenanceDataSet.Equipment.Count; countLines++)
{
foreach (DataRow machine in adapter.GetMachinesBy(lineArray[i].ToString()))
{
string[] machineManufacturerArray = new string[countMachines];
string[] machineTypeArray = new string[countMachines];
string[] equipmentNumberArray = new string[countMachines];
machineManufacturerArray[x] = Convert.ToString(machine.Table.Rows[x][0]);
machineTypeArray[x] = Convert.ToString(machine.Table.Rows[x][1]);
equipmentNumberArray[x] = Convert.ToString(machine.Table.Rows[x][2]);
dynamicMachineCheckbox[x] = new CheckBox();
dynamicMachineCheckbox[x].Location = new System.Drawing.Point((20), (29 + x * 21));
dynamicMachineCheckbox[x].Name = "checkbox" + x;
dynamicMachineCheckbox[x].Width = 250;
dynamicMachineCheckbox[x].Text = machineManufacturerArray[x] + " " + machineTypeArray[x] + " " + "(" + equipmentNumberArray[x] + ")";
this.xtraTabControl2.TabPages[countLines + 1].Controls.Add(dynamicMachineCheckbox[x]);
machineGroupControl.Controls.Add dynamicMachineCheckbox[x]);
//Event sending checkbox data to submitButton_click()
}
}
}
private void submitButton_click(object sender, EventArgs e)
{
//In here i need every checkboxes checkstate and text (i know the code below isn't right)
//if (dynamicMachineCheckbox[x].Checked)
//{ machineCheckboxArray[x] = dynamicMachineCheckbox[x].Text; }
//else { machineCheckboxArray[x] = ""; }
}
Comment