我试图以编程方式更改DataGridViews
“单元格标题”字体样式 Col 标题必须是大写,我想分配一个新字体。如果有人在此之前完成了此操作,我将在此感谢您的指导。
更新
实际上字体更改工作正常,只是headerText.ToUpper()
我需要帮助
private void dataGridView1_Painting(object sender, DataGridViewCellPaintingEventArgs e)
{
//Something like this.
foreach(DataGridViewColumnCollection c in grd.Columns) {
c.ColHeading.Text = c.ColHeading.Text.ToUpper();
}
//or
//header row only
if (e.RowIndex == -1)
{
e.CellStyle.Font = new Font("Verdana", 11.0f);
e.CellStyle.ForeColor = Color.Gray;
e.Value = e.Value.ToUpper(); //fails as its a read only object
}
}