Add combobox column to gridcontrol with winforms

2.1k views Asked by At

I have a GridControl with a loaded datatable to it (with datasource):

DataTable table = GetData();
GridControl1.DataSource = table; 

How can I add a column of comboboxes?

1

There are 1 answers

1
Manu Nair On

You can use the below code, after assigning the datasource into the DataGridView, we have to do the following code.

        dataGridView1.DataSource = dt;
        dataGridView1.Refresh();

        DataGridViewComboBoxColumn cmbColumn = new DataGridViewComboBoxColumn();
        cmbColumn.HeaderText = "Select ComboBox";
        cmbColumn.Name = "ComboBox";
        cmbColumn.MaxDropDownItems = 4;
        cmbColumn.Items.Add("Item1");
        cmbColumn.Items.Add("Item2");
        dataGridView1.Columns.Add(cmbColumn);
        dataGridView1.Refresh();