I read several articles and could not solve the problem. My problem is when I try to get the value of the controls (CheckBox and ComboBox) dynamically added to Windows Form, I need to know when the CheckBox is checked (or not checked), and if the ComboBox is empty (or not) when I click the button , this button calls a method in which I check if all components are empty, I add controls as follows:
CheckBox box; ComboBox cmBox; for (int i = 1; i <= sumOfRegisters; i++) { box = new CheckBox(); box.Name = "CheckBox" + i; box.Text = "Some text"; box.AutoSize = true; box.Location = new Point(10, i * 25); //vertical cmBox = new ComboBox(); cmBox.Name = "ComboBox" + i; cmBox.Size = new System.Drawing.Size(302, 21); cmBox.TabIndex = i; cmBox.Text = "Some Text"; cmBox.Location = new Point(270, i * 25); this.groupBox.Controls.Add(cmBox); this.groupBox.Controls.Add(box); }
"I am adding values ββfrom the database in the case of the ComboBox, I skipped this part."
I am trying to get the value using foreach:
foreach (Control ctrl in groupBox.Controls)
The problem is that I donβt know how to check if Control (CheckBox and ComboBox) is checked or empty (as in the case).
Really thanks for any help, I appreciate your time.
c # checkbox winforms combobox
Fernando armando bernal marin
source share