如题
如何修改datagridview内定义为DataGridViewButtonColumn列的按钮的背景色 不是Cell的背景色
如何修改datagridview内定义为DataGridViewButtonColumn列的按钮的背景色 不是Cell的背景色
解决方案 »
- 邮件发送不成功的问题
- C#对SQL2005同时操作数据库效率问题
- 命名空间同时存在于两个文件中造成的编译不通过
- C#连接SQL Server
- 写一个控制台程序,给字符串中每个单词加上双引号. (寻找更好的解决方法)
- 为何我的timer在运行30分钟后死掉了,不执行了,消失了。。
- 请问哪里有下载中文版vs.net2005的地址(以前我下一个2.8G的)可是帮助不全!!郁闷,要大的,越大越好
- 求.net自动刷新datagrid代码。
- chart控件的Annotation为什么没有能显示出来?
- VS2017 安装部署报错 软件打包
- 调用AnimateWindow方法,是不是属于调用Windows API?
- 线程的结束顺序是?
DataGridViewColumns.FindControl("按钮ID")来获取按钮,然后可以随意改变它的样式
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == 2)
{
e.Handled = true;
using (SolidBrush brush = new SolidBrush(Color.Red))
{
e.Graphics.FillRectangle(brush, e.CellBounds);
}
ControlPaint.DrawBorder(e.Graphics, e.CellBounds, Color.Yellow, ButtonBorderStyle.Outset);
}
}由于DataGridView的Button列是由Graphics绘制上去的,而不是真正的Button控件。所以绘制出来不是很好看,不过button的背景色是改了