Search code examples
c#.netwinformsdatagridviewdatagridviewcombobox

DataGridView - ComboBox as Header Cell


I would like to have a DataGridView with ComboBoxes as Headers. The DGV always has 2 columns. I need the comboBoxes in order to select the unit that the values I fill in are (e.g. first column is going to be sec, min, hr).

I did look up and try the version used at the following entries: MSDN and Stack Overflow (basically the same solution)

Yet I would like the Cell to act just like a ordinary DataGridViewComboBoxCell, which I use at antoher part of my code

        DataGridViewComboBoxCell sensor = new DataGridViewComboBoxCell();
        sensor.DataSource = new String[] { "Kein Sensor", "KTY84", "PTC", "PT1000" };
        engineDataGrid.Rows[10].Cells["value"] = sensor;
        engineDataGrid.Rows[10].Cells["value"].Value = sensor.Items[0];

How can I merge my ordinary Versionen with the Column Headers?


Solution

  • The solution I ended up using is a work around, disabling the column header and using the first row as my header, editing it the way I posted with the question. A bit of editing with the border style and it looks just like it is the original header or to be more precise, a style for the header i like for the application, but as a combobox.