Populate combo box with dataSet

easp

New member
Joined
Mar 12, 2009
Messages
1
Programming Experience
Beginner
Hi everyone,

I'm trying to populate a combo box with a dataset, this sort of works, but everything is just appearing on the same line. I think this answer might be to put the dataset into an array, then put the array into the combo box.

...problem is, I'm not sure how to do this! My code thus far is,


Dim usernameList As Array

'Retrieve usernames where player has available status
GetFilteredData()

'loop to display each record in the DataSet
For i = 1 To CountRecords()

'Append combobox with each player's username
ComboBox1.Text &= GetDsValue(i, 2) & " " & vbCrLf


For inserting the dataset values into the array would I use:
usernameList = GetDsValue(i, 2) & " " & vbCrLf ?

Thanks in advance!
 
Combobox.Text displays the cbo item in the cbo that is currently selected. This is dependent on the cbo actually having items.

Your question is simple to answer but really should take a few minutes to type in Combobox into the help file to get an understanding of the combobox, items, its properties and how to work with it in general, if you dont even understand items.

You can bind the combobox directly to your dataset source such as
VB.NET:
Expand Collapse Copy
With combobox1

       'Set datasource directly to your dataset.table or the array
       .DataSource = myDataset.myTable
   
       'DisplayMember is the field that will be visibile to the user
       .DisplayMember = myTable.Columns("myField")

        'ValueMember is the hidden value to each item 
       .ValueMember = myTable.Columns("myField")
End With
 
Last edited:
Back
Top