Hi!,
I have a GUI with a number of repeating Controls with similar/related data, I encounter a problem everytime I click on the a ComboBox to make a choice, all the fields change their selected fields to the last selection I make. For Example;
if i have 10 Comboboxes with all the data types of a database listed in each of them, on choosing int for one the rest also change to int and so on.
Please Help ASAP!
Cheers
Problem with selecting individual ComboBox in an Array of ComboBox Control
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Muzammil Deshmukh3 reputationPosted Oct 26, 2005, 4:38 AM EDT
for(int i = 0; i < dataTypeComboBox.Length; i++){
this.Controls.Add(this.dataTypeComboBox[i]);
this.dataTypeComboBox[i].DataSource = dataTypes;
}
where dataTypes was;
private
string[] dataTypes = {"bigint", "int", "smallint", "tinyint", "bit", "decimal", "numeric", "money", "smallmoney", "float", "real", "datetime", "smalldatetime", "char", "varchar", "text", "nchar", "nvarchar", "ntext", "binary", "varbinary", "image", "cursor", "sql_variant", "table", "timestamp", "uniqueidentifier"};for(int i = 0; i < dataTypeComboBox.Length; i++){
this.Controls.Add(this.dataTypeComboBox[i]);
this.dataTypeComboBox[i].DataSource = dataTypes;
}
I changed this into;
for(int i = 0; i < dataTypeComboBox.Length; i++){
this.Controls.Add(this.dataTypeComboBox[i]);
this.dataTypeComboBox[i].Items.AddRange(dataTypes);
}
and it works;
Cheers