Here is the code where I setup the combobox. I am using the autogeneration of the columns and trap for the fields that I know are ID fields that link to other tables ( Resource and Project) .
Private Sub SfDataGrid2_AutoGeneratingColumn(sender As Object, e As AutoGeneratingColumnArgs) Handles SfDataGrid2.AutoGeneratingColumn
If e.Column.MappingName = "ResourceID" Then
e.Column.HeaderText = "Name"
If TypeOf e.Column IsNot GridComboBoxColumn Then
e.Column = New GridComboBoxColumn() With {.MappingName = "ResourceID", .HeaderText = "Name", .DisplayMember = "ResourceName", .ValueMember = "ResourceID", .DropDownStyle = DropDownStyle.DropDown, .AutoCompleteMode = AutoCompleteMode.SuggestAppend, .DataSource = Me.ResourceBindingSource}
End If
End If
If e.Column.MappingName = "ProjectID" Then
e.Column.HeaderText = "Project"
If TypeOf e.Column IsNot GridComboBoxColumn Then
e.Column = New GridComboBoxColumn() With {.MappingName = "ProjectID", .HeaderText = "Project", .DisplayMember = "ProjectName", .ValueMember = "ProjectID", .DropDownStyle = DropDownStyle.DropDown, .AutoCompleteMode = AutoCompleteMode.SuggestAppend, .DataSource = Me.ProjectBindingSource}
End If
End If
If InStr(e.Column.MappingName, "Hrs") > 0 Then
e.Column.HeaderText = "Hrs"
e.Column.Width = 60
ElseIf InStr(e.Column.MappingName, "%") > 0 Then
e.Column.HeaderText = "%"
e.Column.Width = 60
End If
End Sub
It does not do the end user any good to display the ProjectID value in the header. For it to make sense to an end user it needs to display the "DisplayMember" value so they will know what data is within each grouping. The ProjectID field is an integer field that is a foreign key to the Project table.
Here is how the grid looks when executed: ( The Name and Project ) columns are both ID fields that link to other tables.