E
Ed West
Hi,
I am dynamically creating Comboboxes and putting them in a panel.
However, they are all referencing the same object! When I change one,
then all of them change. How can I make it so it doesn't do this? I'm
sure this is pretty simple, just can't find the answer. Thanks.
for (int i=0; i < _ds.Tables[0].Columns.Count; i++) {
ComboBox x = new ComboBox();
x.Name = "col" + i.ToString();
x.DataSource = EMRData.DBFieldsDS.Tables[0].DefaultView;
x.DisplayMember = "name";
x.Width = 100;
x.Height = 15;
x.DropDownStyle = ComboBoxStyle.DropDownList ;
x.Location = new Point(x.Width*i + 10, 5);
pnlMapFields.Controls.Add(x);
x = null;
}
any ideas?
-ed
I am dynamically creating Comboboxes and putting them in a panel.
However, they are all referencing the same object! When I change one,
then all of them change. How can I make it so it doesn't do this? I'm
sure this is pretty simple, just can't find the answer. Thanks.
for (int i=0; i < _ds.Tables[0].Columns.Count; i++) {
ComboBox x = new ComboBox();
x.Name = "col" + i.ToString();
x.DataSource = EMRData.DBFieldsDS.Tables[0].DefaultView;
x.DisplayMember = "name";
x.Width = 100;
x.Height = 15;
x.DropDownStyle = ComboBoxStyle.DropDownList ;
x.Location = new Point(x.Width*i + 10, 5);
pnlMapFields.Controls.Add(x);
x = null;
}
any ideas?
-ed