1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex != 2)
return;
if (e.RowIndex < 0)
return;
ProgressBar pb = new ProgressBar();
const int margin = 4;
pb.Width = e.CellBounds.Right - e.CellBounds.Left - (margin * 2);
pb.Value = (int)e.Value;
Bitmap bmp = new Bitmap(pb.Width, pb.Height);
pb.Update();
pb.DrawToBitmap(bmp, pb.ClientRectangle);
e.Graphics.DrawImage(bmp, new Point(e.CellBounds.X +margin, ((e.CellBounds.Bottom - e.CellBounds.Top - pb.Height) / 2) + e.CellBounds.Top));
e.Handled = true;
} |
Partager