简体   繁体   English

DataGridView-ComboBox作为标题单元格

[英]DataGridView - ComboBox as Header Cell

I would like to have a DataGridView with ComboBoxes as Headers. 我想要一个带有ComboBoxes作为标题的DataGridView。 The DGV always has 2 columns. DGV始终有2列。 I need the comboBoxes in order to select the unit that the values I fill in are (eg first column is going to be sec, min, hr). 我需要comboBoxes来选择我要填写的值的单位(例如,第一列将是sec,min,hr)。

I did look up and try the version used at the following entries: MSDN and Stack Overflow (basically the same solution) 我确实查找并尝试了以下条目中使用的版本: MSDNStack Overflow (基本上是相同的解决方案)

Yet I would like the Cell to act just like a ordinary DataGridViewComboBoxCell , which I use at antoher part of my code 但是我希望Cell像普通的DataGridViewComboBoxCell ,在我的代码的另一部分中使用

        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? 如何将普通的Versionen与列标题合并?

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. 使用边框样式进行一些编辑,看起来就像是原始标头,或更准确地说,是我喜欢应用程序的标头样式,但它是一个组合框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM