# CodeGuru Technical FAQs > CodeGuru Individual Visual Basic FAQs >  [VB 2005] Howto Use Bound DataGridViewComboBox Column in Bound DataGridView.

## aniskhan

*Q.* Howto Use Bound DataGridViewComboBox Column in Bound DataGridView.
*Ans.*  Use DataGridView's AutoGenerateColumns property and DataGridViewColumn's DataPropertyName property.

Add DataGridView onto Form and Button (Load Data).
*1.*Declarations

```
    Dim dtSuppliers As DataTable
    Dim dtOrders As DataTable

    Dim OrderNo As DataGridViewTextBoxColumn
    Dim SupplierName As DataGridViewComboBoxColumn
```

*2.*Initialize, Add Columns and Rows to DataTables (Suppliers & Orders)


```
        InitTables()
```

*3.*Disable Automatic column generation


```
        DataGridView1.AutoGenerateColumns = False
```

*4.*Add 2 Columns to DataGridView

```
        'Column 1: OrderNo
        OrderNo = New DataGridViewTextBoxColumn
        OrderNo.HeaderText = "Order No"
        OrderNo.Name = "OrderNo"

        'Column 2: SupplierName
        SupplierName = New DataGridViewComboBoxColumn
        SupplierName.HeaderText = "Supplier Name"
        SupplierName.Name = "SupplierName"

        'Add these Columns to DataGridView Column Collection
        DataGridView1.Columns.AddRange(New DataGridViewColumn() {OrderNo, SupplierName})
```

*5.*Set the DataGridView Columns to Columns in DataSource

```
        DataGridView1.Columns("SupplierName").DataPropertyName = "SupplierID"
        DataGridView1.Columns("OrderNo").DataPropertyName = "OrderNo"
```

*6.*Set SupplierName (DataGridView ComboBoxColumn) DataBinding Properties and Set DataGridView's DataSource.

```
        SupplierName.ValueMember = "SupplierID"
        SupplierName.DisplayMember = "SupplierName"
        SupplierName.DataSource = dtSuppliers
        DataGridView1.DataSource = dtOrders
```

Method Creates two DataTables Suppliers and Orders

```
    Private Sub InitTables()
        dtSuppliers = New DataTable("Suppliers")
        dtOrders = New DataTable("Orders")

        'DataTable Suppliers: SupplierID | SupplierName
        dtSuppliers.Columns.Add("SupplierID", GetType(Integer))
        dtSuppliers.Columns.Add("SupplierName", GetType(String))

        'DataTable Suppliers: OrderNo | SupplierID
        'Use this SupplierID to get SupplierName from Suppliers Table
        'to Show in DataGridView
        dtOrders.Columns.Add("OrderNo", GetType(Integer))
        dtOrders.Columns.Add("SupplierID", GetType(Integer))

        'Add 5 Rows to Both Tables
        Dim row As DataRow
        For i As Integer = 1 To 5
            row = dtSuppliers.NewRow
            row("SupplierID") = i
            row("SupplierName") = "Supplier " & i
            dtSuppliers.Rows.Add(row)

            row = dtOrders.NewRow
            row("OrderNo") = i
            row("SupplierID") = i
            dtOrders.Rows.Add(row)
        Next
    End Sub
```

----------

