可能重复:
在 GridView 的空单元格中显示消息
通过该代码,我将所有单元格都着色了,我只需要一个空单元格.. 有人能注意到我的错在哪里(对不起,我是 C# 新手)
private void simpleButton1_Click(object sender, System.EventArgs e)
{
string[] msg = new string[60];
string[] error = new string[400];
for (int i = 0; i < gridView3.RowCount ; i++)
{
System.Data.DataRow Rows = gridView3.GetDataRow(i);
string cellvalue = Rows[0].ToString();
if (cellvalue == "")
{
msg[0] = "Missing 'First Name'";
error[i] = msg[0] + " - ";
gridView3.CustomDrawCell += new RowCellCustomDrawEventHandler(gridView3_CustomDrawCell);
}
}
}
private void gridView3_CustomDrawCell_1(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
e.Style.BackColor = Color.LightSteelBlue;
}
顺便说一下,这个网格是从 Excel 导入的