读书人

在winfrom程序里头 DataGridViewButto

发布时间: 2012-10-12 10:17:04 作者: rapoo

在winfrom程序里面 DataGridViewButtonColumn列 按键的背景色怎样修改
如题
如何修改datagridview内定义为DataGridViewButtonColumn列的按钮的背景色 不是Cell的背景色

[解决办法]

C# code
  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);            }        } 

读书人网 >C#

热点推荐