在运行时为ColumnHeaderCells着色 [英] Coloring ColumnHeaderCells at Run Time

查看:101
本文介绍了在运行时为ColumnHeaderCells着色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我使用下面的代码为第一列的HeaderCell上色.我不知道为什么它不起作用.我还在设计时设置了ColumnHeadrDefaultStyle属性,但令人惊讶的是,它也没有起作用.我应该怎么做才能完成这么简单的任务?

Hello,

I used the code below to color the HeaderCell of the first column. I wonder why it did not work. I also set the ColumnHeadrDefaultStyle property at design time but amazingly it did not work neither. What should I do to get done such a simple task?

dataGridView1.Columns[0].HeaderCell.Style.ForeColor = Color.Red; 



非常感谢您



Thank you very much

推荐答案

尝试使用其中任何一种更改标题行的背景色

Try any one of this for change the back color of header row

GridView1.HeaderRow.Cells[0].BackColor = Color.Red;
GridView1.Columns[0].HeaderStyle.BackColor = Color.Red;



尝试此操作以更改标题行的文本颜色



Try this for change the text color of header row

GridView1.HeaderRow.Cells[0].ForeColor = Color.Red;
GridView1.Columns[0].HeaderStyle.ForeColor = Color.Red;


这篇关于在运行时为ColumnHeaderCells着色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆