最佳答案
Cell
称为 TopLeftHeaderCell
,您可以像这样设置其 Value
:
dataGridView1.TopLeftHeaderCell.Value = "HIHO";
它甚至有一个带有 Colors
等的 Style
属性。但我发现更改 BackColor
没有效果。除非你改变这个obscure setting为假
:
dataGridView1.EnableHeadersVisualStyles = false;
dataGridView1.TopLeftHeaderCell.Style.BackColor = Color.Gold;
作为替代方案,您还可以拥有该单元格。
这是一个例子:
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex < 0 && e.ColumnIndex < 0)
{
e.Graphics.FillRectangle(Brushes.Gold, e.CellBounds);
e.Handled = true;
}
..
但是你为什么要;-)
关于c# - 更改列标题的 datagridview rowheader 的颜色 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44195687/