title: DataGridView combobox column with datasource
body: <p>Have datagridview which contains 4 columns created manually from creator. 1st, 2nd and 3rd columns are just textbox columns but the last one is marked as comboboxcolumn. </p>
  
  <p>User can add rows to it clicks on some button. Values for first three columns are comming from some textboxes. The problem is i have to populate combobx column when user add his row. What i tried so far was like this:</p>
  
  <pre><code>dgvMaterials.Rows.Add(material, rodzajName, rodzajID, new Variation().GetAll())
  </code></pre>
  
  <p>Note that GetAll function retreiving datatable data inside are Id and Name. Id should be marked as value member and name as display member.</p>
  
  <p>So simply saying user click some button on form tree first column's fields filling up from some textboxes, and last combobox column should be filled up by data from GetAll. How to achieve that?</p>
  
  <hr>
  
  <pre><code>   Private Sub btnAddMatType_Click(sender As Object, e As EventArgs) Handles btnAddMatType.Click
  
              try
                Dim dt as DataTable
                dt = New Variation().GetAll()
  
  
                Dim cbo = CType(dgvMaterials.Columns(3), DataGridViewComboBoxColumn)
                cbo.Items.AddRange(dt.AsEnumerable().Select(Function(s) s.Field(Of String)("Name")).ToArray())
  
                Dim rodzajID as String = TreeMaterials.SelectedValue
                Dim rodzajName as string = TreeMaterials.SelectedNode.Text
                Dim material as string = TreeMaterials.SelectedNode.Parent.Text
  
                dgvMaterials.Rows.Add(material, rodzajName, rodzajID)
  
  
  Catch ex As Exception
                  msgbox(ex.ToString())
  End Try
  </code></pre>
  
  <p>dt contains data:
  <a href="https://i.stack.imgur.com/3yOCs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3yOCs.png" alt="enter image description here"></a></p>
  
  <p>grid look after all (no data in combo):
  <a href="https://i.stack.imgur.com/EAShc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EAShc.png" alt="enter image description here"></a></p>
  
  <p>Drilling into cbo.Items:
  <a href="https://i.stack.imgur.com/y5UUh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y5UUh.png" alt="enter image description here"></a></p>