设置datagridview中button按钮的背景颜色 DataGridViewButtonColumn()在datagridview中创建按钮列,如何设置按钮的背景颜色(不是单元格的背景颜色)。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Button的颜色需要重绘才能改变。 还有问想一下不同的button可以设置不同的背景颜色吗 可以在dataGridView1_CellPainting事件里面处理。private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { if (e.ColumnIndex == 0)//索引0 { 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); } if (e.ColumnIndex == 1)//索引1 { e.Handled = true; using (SolidBrush brush = new SolidBrush(Color.BlueViolet)) { e.Graphics.FillRectangle(brush, e.CellBounds); } ControlPaint.DrawBorder(e.Graphics, e.CellBounds, Color.Yellow, ButtonBorderStyle.Outset); } }效果: 想问一下这个button有透明度吗 DataGridView中的ComboBox小问题(在线等) 请演示一下IComparable 接口和 IComparer接口用法。不太懂。 vs2005发布问题! C#连Orcale的出错 高手们都进来呀. 请大家推荐一本c#语言讲解比较详细的书 visio注释生成sql server数据库描述(看帮助和在网上找不到的问题急!!!) 求助!!! 对前帖“军用飞机视频目标捕捉”的涕血补充! CheckedListBox 怎样设置value? TEXTAREA的简单问题 C#中如何让一个图片附带一个值 c#
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == 0)//索引0
{
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);
}
if (e.ColumnIndex == 1)//索引1
{
e.Handled = true; using (SolidBrush brush = new SolidBrush(Color.BlueViolet))
{
e.Graphics.FillRectangle(brush, e.CellBounds);
}
ControlPaint.DrawBorder(e.Graphics, e.CellBounds, Color.Yellow, ButtonBorderStyle.Outset);
}
}
效果: