DataGridView - OnCellPainting - PaintBackground

  • Thread starter Thread starter Florian Schmidt
  • Start date Start date
F

Florian Schmidt

Hello,

since the german newsgroup couldn't help with this issue, I'll post it
here:

I am trying to change the background color of some cells in my
dataGridView, but only partly. Therefore I am overriding the
OnCellPainting-method in my DataGridView like:

Rectangle groupBounds = new Rectangle(
e.CellBounds.X,
e.CellBounds.Y +
Convert.ToInt32(e.CellBounds.Height * 0.5),
e.CellBounds.Width,
Convert.ToInt32(e.CellBounds.Height * 0.5)
);
e.PaintBackground(groupBounds, false);

BUT the e.PaintBackground(...) seems to ignore the new bounds, which
are given in the argument "groupBounds". I can set "groupBounds" to
whatever I want, but it allways paints the whole background.

If I use e.Graphics.FillRectangle(..) it works like expected. But
shouldn't the e.PaintBackground(...) work as well?

Regards
Flo
 
Back
Top