Hello my code example is :
/* bdEmpresa (BindingSource) Contains:
selet idEmpresa,Nombre,Acceso from Empresa
Result
1, Empresa1,true
2, Empresa2,false
3, Empresa2,true
*/
clEmpresas.DataSource = bdEmpresa
clEmpresas.DisplayMember = ? (Nombre)
clEmpresas.ValueMember = ? (Acceso)
This is the code we would use
With clEmpresas.Properties
If .DataSource IsNot Nothing Then .DataSource = Nothing
.DataSource = bdEmpresa
If .DataSource.rows.count = 0 Then Return Nothing 'no data to load
'get the names from the dataset, don't expect them to be specific names
.ValueMember = .DataSource.rows(0).Table.Columns(0).ColumnName
.DisplayMember = .DataSource.rows(0).Table.Columns(1).ColumnName
'Set the selected items, comma separated list of ids
If selectedIds <> "" Then
For i As Integer = 0 To .ItemCount - 1
If Array.IndexOf(selectedIds.Split(","), .GetItemValue(i).ToString) >= 0 Then
.SetItemChecked(i, True)
End If
Next
End If
End With