C# DataGridView设置背景颜色、文字颜色及文字样式

这篇博客详细介绍了如何使用C#编程语言修改Windows Forms应用程序中DataGridView控件的样式。内容包括设置行表头和列表头的背景色与前景色,字体样式,表格的背景色和选中状态的颜色,以及文字样式等,旨在提升界面的视觉效果和用户体验。
摘要由CSDN通过智能技术生成
//行表头和列表头文字颜色
dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.DarkSlateGray;
dataGridView1.RowHeadersDefaultCellStyle.BackColor = Color.DarkSlateGray;
//行表头和列表头文字颜色
 dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.Cyan;
 dataGridView1.ColumnHeadersDefaultCellStyle.Font = new Font("楷体", 12, FontStyle.Bold);
dataGridView1.RowHeadersDefaultCellStyle.ForeColor = Color.Cyan;
dataGridView1.RowHeadersDefaultCellStyle.Font = new Font("楷体", 12, FontStyle.Bold);
//表格背景色            
dataGridView1.DefaultCellStyle.BackColor = Color.DarkSlateGray;
dataGridView1.DefaultCellStyle.SelectionBackColor = Color.Teal;
//表格文字样式         
dataGridView1.RowsDefaultCellStyle.Font = new Font("楷体", 12, FontStyle.Bold);
dataGridView1.RowsDefaultCellStyle.ForeColor = Color.Cyan;
dataGridView1.DefaultCellStyle.SelectionForeColor = Color.Yellow;
 dataGridView1.EnableHeadersVisualStyles = false;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值