Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27333

VS 2008 Using DataGrid with DataTable source - problem adding Combobox to one column

$
0
0
Hi!

I have a DataGridView, it's DataSource is set to a DataTable. One column in the table has only three possible values "C","N","O". I managed to get a ComboBox showing in the DataGridView in a new Column with this code:
Code:

Dim cmb As New DataGridViewComboBoxColumn()
            Dim myTab As New DataTable
            myTab.Columns.Add("id", GetType(String))
            myTab.Columns.Add("value", GetType(String))
            myTab.Rows.Add("C", "certified")
            myTab.Rows.Add("O", "controlled")
            myTab.Rows.Add("N", "unknown")

            Dim GColumn As New DataGridViewComboBoxColumn
            GColumn.HeaderText = "Certification"
            GColumn.DataSource = myTab
            GColumn.DisplayMember = "value"
            GColumn.ValueMember = "id"
            newGrid2.Columns.Add(GColumn)

However, I don't know how to link this cell to the according value in the column of the DataGridView.
Should I update the combobox of each row one by one? This does not seem to be a nice solution to me.

Viewing all articles
Browse latest Browse all 27333

Trending Articles