Combo Control array - Selection

  • Thread starter Thread starter Sylesh Nair
  • Start date Start date
S

Sylesh Nair

hello ,

I have created a Control array for a ComboBox to populate on a tabPage .
My concern is that I 'm using a List to populate the Combo Box like this ..

ComboArray.Items.Add(List[i)];

ComboArray.DataSource = List;

The Combo Box gets populated with all the values in the List ( Thats what I
wanted )
But when i select a value in the First Combo box the Changes reflects in all
the boxes created
Example
if if there were 6 values from 1,2,3 ..6 in the all Combo Dropdown list .
when I select 5 in the 3rd all the Combo's selected value changes to 5.
How do I get specifice values in different Combo According to my selection ?

Thanks
Sylesh Nair
 
It sounds like all the items in your comboArray point to the same
instance of the ComboBox instead of different instances.

Check the code you used to create the array (post it if it's short).
I'll bet that's where the problem lies.

Chris
 
thanks for the reply
here is the code for the Combo boX Creation .

for(int i = 0; i < Number; i++)

{

this.List.Add( new System.Windows.Forms.ComboBox() );

((System.Windows.Forms.ComboBox)this.List).Location = new
System.Drawing.Point(180, 36 + i * 40);

((System.Windows.Forms.ComboBox)this.List).Name = "UC_Combo" +
i.ToString();

((System.Windows.Forms.ComboBox)this.List).Size = new
System.Drawing.Size(184,20);

((System.Windows.Forms.ComboBox)this.List).TabIndex = i + 2;

((System.Windows.Forms.ComboBox)this.List).Text = String.Empty;

((System.Windows.Forms.ComboBox)this.List).Tag = this.Count;

((System.Windows.Forms.ComboBox )this.List).DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;

this.Form1.Controls.Add( ((System.Windows.Forms.ComboBox)this.List) );

}



Thanks

Sylesh
 
It looks like I lost my bet. I can't see anything wrong with that
code. What kind of object is this.List? Are you using any kind of
data binding? What does the SelectedItem event code look like?
It's very puzzling.

Chris
 
Back
Top