如何更改datagridview的列的颜色? [英] how to change color of a column in datagridview?

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

问题描述

我有一个DataGridView,而我设置了一些列的为只读数据输入的目的。当我这样做,列保持正常的白色(尽管它不允许进入)。我怎样才能颜色列灰色?我见过很多样对如何着色行,但不列。

I have a DataGridview, and I'm setting some of the columns to readonly for data entry purposes. When I do that, the column stays the normal white (although it does not allow entry). How can I color the column gray? I've seen lots of samples on how to color rows, but not columns.

我怎样才能让只读列看起来是灰色的?

How can I make the readonly columns look gray?

推荐答案

尝试设置在 DefaultCellStyle 属性选定列。

Try setting the DefaultCellStyle property for the selected columns.

编辑:

grid.Columns["NameOfColumn"].DefaultCellStyle.ForeColor = Color.Gray;

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

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