现在,datagridView标题背景颜色以灰色显示.我想改成差异
颜色.
颜色.
我在ColumnHeaderDefaultCellStyle中更改了背景颜色,但没有任何改变.
这该怎么做.
解决方法
在datagridView中,您可以使用
DataGridViewCellStyle更改标题颜色,请参阅以下代码
' Set the selection background color for all the cells. dataGridView1.DefaultCellStyle.SelectionBackColor = Color.White dataGridView1.DefaultCellStyle.SelectionForeColor = Color.Black ' Set RowHeadersDefaultCellStyle.SelectionBackColor so that its default ' value won't override DataGridView.DefaultCellStyle.SelectionBackColor. dataGridView1.RowHeadersDefaultCellStyle.SelectionBackColor = Color.Empty ' Set the background color for all rows and for alternating rows. ' The value for alternating rows overrides the value for all rows. dataGridView1.RowsDefaultCellStyle.BackColor = Color.LightGray dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.DarkGray ' Set the row and column header styles. dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.White dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.Black dataGridView1.RowHeadersDefaultCellStyle.BackColor = Color.Black
编辑:
使用DataGridViewCellStyle,标题颜色将更改,但标题部分中的列的分隔符将不会出现.所以,继承人OnPaint Event Handler的一个重要事件看看this
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。