C#WINFORM中的DATAGRID控件问题,高手请进 我现在用DATAGRID控件显示了一张表的数据,期中有一列是数字,我想实现这些数字>50的用红色字体显示,<50的用绿色字体显示,请问各位高手应该如何实现,强调一点是WINFORM中。最好就我的这个例子给出代码,谢谢了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 int tmp = 0; //取数字for(int i = 0; i < dg.Rows.Count; i++){ tmp = int.Parse(dg.Rows[i].Cells["数字列"].ToString()); if(tmp > 50) { ((DataGridViewTextBoxColumn)dg.Rows[i].Cells["数字列"]).ForeColor = Color.Red; } else ........ = 绿色;}_________________________________ 仅提供思路作为参考!! 多看看MSDN类库.继承.. 这样就行了以前做过一次,是用drawing画上去的,那个很慢现在想想有简单的办法的 http://www.ouaox.cn/index.php?9670-1.html 设置DataGridColoredTextBoxColumn参考参考 谢谢各位了,解决了,我改写了下代码 float tmp = 0; for (int i = 0; i < dataGridView1.Rows.Count; i++) { float tmp = float.Parse(dataGridView1.Rows[0].Cells[1].Value.ToString()); if (tmp > 50) { dataGridView1.Rows[i].Cells[1].Style.ForeColor = Color.Red; } }谢谢各位的启发 很有难度的算法问题,想挑战的可以进来看下 C#打开远程计算机目录 新手问题 C#求一个随机生成不重复4位数的方法 udp Socket 发送缓冲区 最大可以为多大?Socket.SendBufferSize 一个如何增加页面的问题 散分: 来自水比尿水还臭 来自无锡的生活实况 一个简单的问题,数据库查找是否为空怎么判断? C#控制IE窗口位置 如何使用正则表达式匹配非特定字串? 如何调用PC喇叭发出"嘀-嘀-嘀"的声音? savefiledialog 文件名不输入如何报错 c#MDI窗体问题
int tmp = 0; //取数字
for(int i = 0; i < dg.Rows.Count; i++)
{
tmp = int.Parse(dg.Rows[i].Cells["数字列"].ToString());
if(tmp > 50)
{
((DataGridViewTextBoxColumn)dg.Rows[i].Cells["数字列"]).ForeColor = Color.Red;
}
else
........ = 绿色;
}_________________________________ 仅提供思路作为参考!! 多看看MSDN类库.继承..
这样就行了以前做过一次,是用drawing画上去的,那个很慢
现在想想有简单的办法的
参考
参考
float tmp = 0;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
float tmp = float.Parse(dataGridView1.Rows[0].Cells[1].Value.ToString());
if (tmp > 50)
{
dataGridView1.Rows[i].Cells[1].Style.ForeColor = Color.Red; }
}
谢谢各位的启发