Thanks i solved my problem by creating a custom class to handle my combo
boxes, and added the class object from an exampe off the web and it worked
okay, and also improved the performance of loading much faster.
if anyone is interested, heres the code for reference:
----------------------------------------------
Public Class ComboFiller
Public txtShow As String
Public value As String
Public text As String
Sub New(ByVal value As String, ByVal text As String, ByVal pText As
String)
Me.txtShow = pText
Me.value = value
Me.text = text
End Sub
Overrides Function ToString() As String
Return txtShow
End Function
End Class
Sub LoadSuppliers()
cbSuppliers.Items.Clear()
cmd.CommandType = Data.CommandType.Text
cmd.CommandText = "SELECT supplierid, description FROM suppliers
ORDER BY description ASC"
drTemp = cmd.ExecuteReader()
If Not (drTemp Is Nothing) Then
cbSuppliers.Items.Add(New ComboFiller("", "", ""))
While drTemp.Read
cbSuppliers.Items.Add(New ComboFiller(drTemp(0), drTemp(1),
drTemp(1).ToString))
End While
drTemp.Close()
End If
drTemp = Nothing
End Sub
----------------------------------------------
thanks,
Paul
Chris Oswald said:
ComboBox.DataSource = dt
ComboBox.DisplayMember = "ColumnName"
The column name is obviously the column you want to be displayed in the
Combo Box.
You can also assign a different value by using ValueMember.
hi there,
im using a datatable to fill a combo box but when i try "dt.rows.add(new
object(){"",""}) all the items in the combo box say
"system.data.datarow[]"
instead of their values.
How can i populate a combo box manually and assign the string and value
to
how i want?
thanks,
Paul