社区
C#
帖子详情
DataGridView 设置渲染某个行的颜色,点击列头排序以后渲染的设置没有了
刘乐钢铁
2020-09-22 08:57:19
遇到这种情况该怎么处理呢?
...全文
8910
3
打赏
收藏
DataGridView 设置渲染某个行的颜色,点击列头排序以后渲染的设置没有了
遇到这种情况该怎么处理呢?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
Antony_WU_SZ
2020-10-20
打赏
举报
回复
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if(dataGridView1.Columns[e.ColumnIndex].Name.Contains("Result")) { String stringValue = e.Value as string; if (stringValue!=null) { if (stringValue.ToLower().Contains("error")) { e.CellStyle.BackColor = Color.Red; } else if(stringValue.ToLower().Contains("warning")) { e.CellStyle.BackColor = Color.Yellow; } } } else if (dataGridView1.Columns[e.ColumnIndex].Name.Contains("ModuleName")) { String stringValue = e.Value as string; if (stringValue != null) { if (stringValue.ToLower().Contains("error") || stringValue.ToLower().Contains("disk")) { e.CellStyle.BackColor = Color.Red; } else if (stringValue.ToLower().Contains("warning")) { e.CellStyle.BackColor = Color.Yellow; } } } } 含特殊字符的变颜色,很简单,供参考!
刘乐钢铁
2020-10-19
打赏
举报
回复
非常感谢,我去试一下。
shisee922
2020-09-22
打赏
举报
回复
设置dataGridView1_CellPainting事件 private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { if (e.RowIndex < 0) return; DataGridViewRow row = dataGridView1.Rows[e.RowIndex]; if (true) //设置需要改变颜色的条件 { row.Cells[0].Style.BackColor = Color.Gainsboro; //设置单元格背景色 } }
DataGridView
实现自定义
点击
列头
升序和降序
排序
DataGridView
实现自定义
点击
列头
升序和降序
排序
C#中关于
DataGridView
行
和列的背景色及列标题的背景
颜色
设置
地址:C#中关于
DataGridView
行
和列的背景色-前景色
设置
_c#
datagridview
.defaultcellstyle-CSDN博客
C#
设置
DataGridView
行
背景色无效的问题
C#
设置
DataGridView
行
背景色无效的问题
设置
代码 for (int i = 0; i <
dataGridView
1.RowCount; i++) { if (i % 2 == 0) {
dataGridView
1.Rows[i].DefaultCellStyle.BackColor = Color.SeaGreen; ...
datagridview
row
行
宽_C#窗体控件
DataGridView
常用
设置
默认情况下,最后一
行
空白表示自动新增
行
,对于需要在控件中进
行
编辑,可以保留
dataGridView
1.AllowUserToAddRows = false;上述禁用,仅是将用户界面交互的自动新增
行
禁了,但还是可以通过代码:
dataGridView
1.Rows....
DataGridView
控件用法(一)绑定数据-修改列值-序号列-交换列顺序
DataGridView
控件用法(一):绑定数据-修改列值-序号列-交换列顺序 Wind 撰写于 2012 年 3 月 21 日 | 分类 :C# Winform程序开发 |
没有
评论 | 10,200 次浏览 一、
DataGridView
控件的用法(如何绑定、...
C#
110,529
社区成员
642,572
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章