【发布时间】:2013-03-03 03:21:17
【问题描述】:
我正在使用 Windows 窗体中的数据网格视图,并为其分配数据源属性以加载网格。我想更改某些单元格的背景色(当列索引 = 0 时)但是 当我这样做并调整表单大小时,我遇到了问题,数据网格变得模糊或单元格未正确显示。这些图片会更好地解释它。
调整大小之前:
调整大小后:
这是我尝试格式化单元格的代码...
private void dg_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
// Clients color
if (e.ColumnIndex == 0)
{
int currentClient = e.RowIndex % p.AllClients.Count;
dg.Rows[e.RowIndex].Cells[0].Style.BackColor = Color.FromArgb(p.AllClients[currentClient].Color);
}
}
提前致谢!
【问题讨论】: