G
Guest
Hi there,
I'm using VS.NET 2003 / VB.NET and binding a strongly-typed dataset (Fln1)
to my combobox. The strongly-typed dataset is displayed in the component
"tray" on my form, so at design time, I can configure the combobox to bind to
Fln1, and the Windows Forms Designer generates the following code:
Me.ComboBox1.DisplayMember = "LOCTYPE.LocationType"
Me.ComboBox1.ValueMember = "LOCTYPE.LocationType"
Me.ComboBox1.DataSource = Me.Fln1
Me.ComboBox1.DataBindings.Add(New
System.Windows.Forms.Binding("SelectedValue", Me.Fln1, "FLN.LocationType"))
So this looks right... I thought!
In the Form_Load event of my Form, I fill up the dataset (Fln1) with the
data needed, and the form displays itself - but the combobox is not bound
correctly: it is positioned at the first item in the combobox, not the
correct one for the dataset contents!
BUT, if I take those EXACT same lines of code and move them from the "
Windows Form Designer generated code " section to the Form_Load event, the
combobox functions correctly - the right element in the Combobox is selected!
Aaaarrrgghhhh!?!?!?! Why? I would like to be able to configure this at
design-time, not waiting until run-time, does anyone have any ideas what I'm
doing wrong?
- David McClelland
I'm using VS.NET 2003 / VB.NET and binding a strongly-typed dataset (Fln1)
to my combobox. The strongly-typed dataset is displayed in the component
"tray" on my form, so at design time, I can configure the combobox to bind to
Fln1, and the Windows Forms Designer generates the following code:
Me.ComboBox1.DisplayMember = "LOCTYPE.LocationType"
Me.ComboBox1.ValueMember = "LOCTYPE.LocationType"
Me.ComboBox1.DataSource = Me.Fln1
Me.ComboBox1.DataBindings.Add(New
System.Windows.Forms.Binding("SelectedValue", Me.Fln1, "FLN.LocationType"))
So this looks right... I thought!
In the Form_Load event of my Form, I fill up the dataset (Fln1) with the
data needed, and the form displays itself - but the combobox is not bound
correctly: it is positioned at the first item in the combobox, not the
correct one for the dataset contents!
BUT, if I take those EXACT same lines of code and move them from the "
Windows Form Designer generated code " section to the Form_Load event, the
combobox functions correctly - the right element in the Combobox is selected!
Aaaarrrgghhhh!?!?!?! Why? I would like to be able to configure this at
design-time, not waiting until run-time, does anyone have any ideas what I'm
doing wrong?
- David McClelland