Goal
I want to have a DataGridViewComboBoxCell after setting my DataGridView's DataSource with a DataView.
Current Situation
I have a DataTable that is populated with BillDetails
as the user navigates through his Bills
.
I created a DataView and set the DataView's Table to equal to the DataTable of Bill Details. I then set the DataGridView's DataSource to the DataView.
Setting the DataGridView's DataSource
Dim ViewContent As New DataView
ViewContent.Table = dsBillMat.Tables("dtBillDetails") 'Set the DataTable to my DataView's Table
ViewContent.RowFilter = "FK_BillHeader = '" & Bill.PK_BillHeader & "'" 'Filter the tables to get the correct Details for the corresponding Bill
dgvArticles.DataSource = ViewContent
FormatContentGridView() 'Formats the DataGridView Headers, Visible columns, etc.
FormatContentGridView
Code to format my DataGridView. Probably where I would need to add code for my ComboBoxCell?
Private Sub FormatContentGridView()
With dgvArticles
'Hide columns
.Columns("PK_BillDetail").Visible = False
.Columns("FK_BillHeader").Visible = False
'Header text
.Columns("ILNum").HeaderText = "# IL"
.Columns("ArtNum").HeaderText = "# Article"
.Columns("Description").HeaderText = "Description"
.Columns("PartNum").HeaderText = "# Pièce"
.Columns("Quantity").HeaderText = "Qté."
.Columns("Manufacturer").HeaderText = "Manufacturier"
.Columns("ShippedLose").HeaderText = "Sép."
.Columns("OnHand").HeaderText = "En Main"
.Columns("RSPL").HeaderText = "RSPL"
.Columns("Code").HeaderText = "Code"
.Columns("Cost").HeaderText = "Coût ($)"
'Widths
.Columns("Description").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
.Columns("Description").MinimumWidth = 150
For Each c As DataGridViewColumn In dgvArticles.Columns
If c.Visible And c.AutoSizeMode <> DataGridViewAutoSizeColumnMode.Fill Then
c.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
End If
Next
'Display Index
.Columns("ILNum").DisplayIndex = 0
.Columns("ArtNum").DisplayIndex = 1
.Columns("Description").DisplayIndex = 2
.Columns("PartNum").DisplayIndex = 3
.Columns("Quantity").DisplayIndex = 4
.Columns("Manufacturer").DisplayIndex = 5
.Columns("ShippedLose").DisplayIndex = 6
.Columns("OnHand").DisplayIndex = 7
.Columns("RSPL").DisplayIndex = 8
.Columns("Code").DisplayIndex = 9
.Columns("Cost").DisplayIndex = 10
End With
End Sub
This works great, the information is populated succesfully. I just don't have my ComboBoxCell yet.
Problem
My issue is, I must have a DataGridViewComboBoxCell for the Code column (red rectangle above). How do I set a DataGridViewComboBoxCell when the column is already created with the DataSource's DataView?