ComboBox cmbx; int k=0; for (int i = 0; i < n; i++) { cmbx = new ComboBox(); cmbx.Name = string.Format("MyCmb_{0}", i.ToString()); cmbxf.Text="yes"; cmbxf.Items.Add("yes"); cmbxf.Items.Add("no"); tableLayoutPanel1.Controls.Add(cmbx); } for (int i=0;i<m;i++) if (cmbx[i].SelectedItems==1) k++; ///// How to doing it?????????
public class ClassName { // define list of combobox in your class public List<combobox> comboboxes {get;set;} public ClassName() { comboboxes = new List<combobox>(); } private void AddItems() { // in your for loop add items to tableLayoutPanel1.Controls // also add the same item to comboboxes like below // comboboxes.Add(cmbx ); } private void CountItems() { // now you can check the selected items count from comboboxes list } }</combobox></combobox>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)