Link to home
Start Free TrialLog in
Avatar of sherrick123
sherrick123

asked on

Filling a combobox with unique records from dataset

I want to fill in a combobox with unique records from my data set.
        ds = New dsBeamProperties
        ta = New dsBeamPropertiesTableAdapters.tblBeamPropertiesTableAdapter
        ta.Fill(ds.tblBeamProperties)
        Dim i As Integer
        i = 0
        Dim rf As dsBeamProperties.tblBeamPropertiesRow

        For Each rf In ds.tblBeamProperties
            cboBeamTypes.Items.Add(rf.Type)
        Next
ASKER CERTIFIED SOLUTION
Avatar of Priest04
Priest04
Flag of Serbia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This absolutely can be done very easy with the following syntax:

'First, instead of declaring rf as the following:
Dim rf As dsBeamProperties.tblBeamPropertiesRow

'Declare rf as a regular DataRow:
Dim rf As System.Data.DataRow

'Use the ToTable method of the DefaultView for the DataTable, and
'     include the "True" parameter for distinct rows, and column names you want returned.
For Each rf In ds.tblBeamProperties.DefaultView.ToTable(True,  "Type").Rows
            cboBeamTypes.Items.Add(rf.Item("Type"))
Next