首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C#2005的DataGridView有关问题

2012-01-11 
C#2005的DataGridView问题如何让DataGridView的某一些特殊的数据设置成红色呢?例如:单据编号金额出仓仓库

C#2005的DataGridView问题
如何让DataGridView的某一些特殊的数据设置成红色呢?
例如:
单据编号 金额 出仓仓库名称 ........等
B000001 10000.00 某某仓库
B000002 20000.00 某某仓库B000003 30000.00 某某仓库


比如:单据编号B000002已经打印过了...数据库中有记录的...
那现在我想把编号B000002的这一行数据(字体设置为红色)怎么搞呢? 不是背景设置为红色而是字体
请高手们帮帮忙 谢谢...

[解决办法]
for(int i=0;i<this.DataGridView1.Rows.count;i++)
{
if(满足条件)
{
this.DataGridView1.Rows[i].ForeColor = Color.Red; 
}
}
[解决办法]
this.dataGridView1.Rows[3].DefaultCellStyle.ForeColor = Color.Red;
[解决办法]
for(int i=0;i <this.DataGridView1.Rows.count;i++) 

if(满足条件) 
{ //修改前景和背景色
this.dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.Red;
或者this.dataGridView.Rows[i].DefaultCellStyle.ForeColor = Color.Yellow;


}

热点排行