Wednesday, October 22, 2014

How to convert the DatagridView cell from textbox to combobox

Here is the code for converting the DatagridView cell from textbox to combobox

But make sure that you are populating the combo box with the items available in the datagrid cells. Otherwise it will give error msg. As shown in the example the datas in the text box also should be as same as the combobox.


With DataGridView1
        If .Rows.Count = 0 Then Exit Sub
        i = Datagridview1.currentrow.index

        Dim gridComboBox As New DataGridViewComboBoxCell
        gridComboBox.Items.Add("PR") 'Populate the Combobox
        gridComboBox.Items.Add("AB") 'Populate the Combobox
        gridComboBox.Items.Add("SL") 'Populate the Combobox
        .Item(8, i) = gridComboBox
    End With

No comments:

Post a Comment