Groups | Blog | Home
all groups > dotnet windows forms databinding > june 2006 >

dotnet windows forms databinding : 3 Comboboxes bound to one Datatable


gwkucki
6/27/2006 5:37:40 AM

I have bound via Datasource tree comboboxes to the same Datatable.
Valuemember and Displaymember are set to the same fieldname. The
selectedvalue i've planed to set individually.

While runing, every change in an combobox changes all three comboboxes.

Why the three Comboboxes change selectedvalue synchronus?

Here is the source

cmd_Kunden = New SqlCommand("select * from Kunden as K", cn)
da_Kunden = New SqlDataAdapter(cmd_Kunden)
da_Kunden.Fill(dt_Kunden)

ComboBox1.DataSource = dt_Kunden
ComboBox1.ValueMember = "ID"
ComboBox1.DisplayMember = "Kunde"

ComboBox2.DataSource = dt_Kunden
ComboBox2.ValueMember = "ID"
ComboBox2.DisplayMember = "Kunde"

ComboBox3.DataSource = dt_Kunden
ComboBox3.ValueMember = "ID"
ComboBox3.DisplayMember = "Kunde"


Thanks GWKucki

Dan Normington
8/21/2006 12:00:00 AM
Try using the Copy() method of the DataTable. I think you'll have to bind
your other combo boxes to copies rather than the original list.

[quoted text, click to view]

AddThis Social Bookmark Button