【发布时间】:2019-01-04 21:46:52
【问题描述】:
似乎 DataGridView 中的文本字体与背景颜色相似,因此在单击或选择单元格之前我看不到任何数据。我试图在DefaultCellStyle 中更改颜色,但什么也没发生。我该如何解决?
这是我的DefaultCellStyle 代码:
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
dataGridViewCellStyle1.ForeColor = System.Drawing.Color.Red;
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
应该没问题,就像在这个预览中一样:
但事实并非如此:
【问题讨论】:
-
前景色是透明的,会影响文字颜色
-
@AleksaRistic 将其更改为红色,我仍然有这个问题。仅在 CellStyle Builder 预览中看起来不错
-
当你从那个窗口改变它时,检查是否在代码中应用了改变
-
@AleksaRistic 是的,但是当我编译我的程序并运行它时,它会变回透明,但不在设计器代码中,只是在属性中。好奇怪……
-
好吧,我只是在 form.cs 中以编程方式更改了它
标签: c# database windows winforms