G
Guest
Hi
I'm having problems getting the correct item to display in a bound combobox
in my WinForms app. Using the following code:
With Me.MyComboBox
.ValueMember = "MyIdField"
.DisplayMember = "ToString"
.DataSource = MyDataTable
End With
'MyDataTable is a table in the MyExampleDataSet, which I have the following
user code in:
Partial Class MyExampleDataSet
Partial Class MyDataTable_GetAllRow
Public Overrides Function ToString() As String
'return Id and Description e.g. 12 - Computer Books
Return String.Format("{0} - {1}", Me.MyIdField,
Me.MyDescriptionField)
End Function
End Class
End Class
The problem is that the ToString method is never called when databinding, so
the ComboBox only displays "System.Data.DataRowView" for each item. I would
like it to display items such as:
12 - Computer Books
14 - Cookery Books
etc.
What am I missing here?
thanks
Richard
I'm having problems getting the correct item to display in a bound combobox
in my WinForms app. Using the following code:
With Me.MyComboBox
.ValueMember = "MyIdField"
.DisplayMember = "ToString"
.DataSource = MyDataTable
End With
'MyDataTable is a table in the MyExampleDataSet, which I have the following
user code in:
Partial Class MyExampleDataSet
Partial Class MyDataTable_GetAllRow
Public Overrides Function ToString() As String
'return Id and Description e.g. 12 - Computer Books
Return String.Format("{0} - {1}", Me.MyIdField,
Me.MyDescriptionField)
End Function
End Class
End Class
The problem is that the ToString method is never called when databinding, so
the ComboBox only displays "System.Data.DataRowView" for each item. I would
like it to display items such as:
12 - Computer Books
14 - Cookery Books
etc.
What am I missing here?
thanks
Richard