I have a Dataset and Datatable (which is typed but empty when I assign the bindingsource) and I'm trying to get that to show in a combobox. Here's the relevent sections:
On the form I added BindingSource1
Declarations
The table:
Then the bindingsource and combobox stuff
When I fill the dataset I get System.Data.DataRowView instead of the ListEntry text. If I assign the table itself as the datasource then I get the proper ListEntry text.
I've tried different ordering of the assigmnents and googled all morning but I can't see where I'm going wrong.
On the form I added BindingSource1
Declarations
VB.NET:
Dim dsetMySet As DataSet = New DataSet("MySet")
Dim dtMyTable1 As DataTable = New DataTable("MyTable1")
The table:
VB.NET:
dtMyTable1.Columns.Add("Serial", GetType(System.Int32))
dtMyTable1.Columns("Serial").Caption = "Serial #"
dtMyTable1.Columns.Add("Name", GetType(System.String))
dtMyTable1.Columns("Name").Caption = "Name"
dtMyTable1.Columns.Add("ListEntry", GetType(System.String))
dtMyTable1.Columns("ListEntry").Caption = "Oops"
dtMyTable1.Columns("ListEntry").Expression = "Serial + ' ' + Name"
kprimarykey(0) = dtMyTable1.Columns("Serial")
dtMyTable1.PrimaryKey = kprimarykey
dsetMySet.Tables.Add(dtMyTable1)
Then the bindingsource and combobox stuff
VB.NET:
BindingSource1.DataMember = "MyTable1"
BindingSource1.DataSource = dsetMySet
ComboBox1.DisplayMember = "ListEntry"
'ComboBox1.ValueMember = "Serial"
ComboBox1.DataSource = BindingSource1
When I fill the dataset I get System.Data.DataRowView instead of the ListEntry text. If I assign the table itself as the datasource then I get the proper ListEntry text.
I've tried different ordering of the assigmnents and googled all morning but I can't see where I'm going wrong.