【发布时间】:2019-11-14 17:08:19
【问题描述】:
关于changing cell background color in a DataGridView 编程的问题
但是有没有办法为特定列设置背景颜色使用 WinForms 设计器?
【问题讨论】:
标签: c# .net winforms datagridview
关于changing cell background color in a DataGridView 编程的问题
但是有没有办法为特定列设置背景颜色使用 WinForms 设计器?
【问题讨论】:
标签: c# .net winforms datagridview
右键单击 DataGridView 并选择编辑列
选择 DefaultCellStyle 属性并单击样式向导
在 CellStyle Builder 窗口中,您可以设置任何您喜欢的属性,包括 BackColor
这将在InitializeComponent()
private void InitializeComponent()
{
/// ...
this.ShadedColumn.DefaultCellStyle.BackColor = Color.Silver;
/// ...
}
* 其中 this.ShadedColumn 是您添加的 DataGridViewTextBoxColumn 控件的名称
InitializeComponent 中的任何代码都将在设计器视图期间执行,从技术上讲,您可以直接在此处更新大多数样式,但建议使用 GUI 表单构建器对此文件进行任何更改
【讨论】: