是否热衷于仅在datagridview中更改特定列标题的颜色? [英] Hot to change specific column header color only in datagridview?

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

问题描述

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

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

我需要为特定列的Header部分的字体/背景上色。我发现只能完成整个列列表的标题,而不是单个列。

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天全站免登陆