仅在datagridview中更改特定的列标题颜色 [英] change specific column header color only in datagridview

查看:1028
本文介绍了仅在datagridview中更改特定的列标题颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用:VS 2005,C#,DataGridView,WinForms;

Uses: VS 2005, C#, DataGridView, WinForms;

我需要对特定列的标题部分的字体/背景进行着色。我看到它只能对整个列列表的标题而不是单个列进行。任何帮助非常感谢。

I need to color the font/background of a particular column's Header portion. I see that it can only be done to the entire column list's header instead of a single column. Any help greatly appreciated.

推荐答案

首先在DataGridView中,您需要将EnableHeadersVisualStyles设置为false。
完成后,您可以在每列上设置单个标题样式。

First in your DataGridView you need to set EnableHeadersVisualStyles to false. After you've done that you can set the individual header style on each column.

        DataGridViewColumn dataGridViewColumn = dataGridView1.Columns[0];
        dataGridViewColumn.HeaderCell.Style.BackColor = Color.Magenta;
        dataGridViewColumn.HeaderCell.Style.ForeColor = Color.Yellow;

这篇关于仅在datagridview中更改特定的列标题颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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