0

I have a custom derivative of a DataGridView. I'm looking to change the positions where some rows will be drawn: starting from a certain index forward, I want to move each row below that row one row-height lower, so I can paint custom shapes in the resulting space between rows. What I thought of is overriding OnRowPrePaint and checking whether the row index is greater than the threshold row. If it is, I want to move the row down:

private void MoveRows(DataGridViewRowPrePaintEventArgs e)
{
    if(e.RowIndex >= thresholdRowIndex)
    {
        e.RowBounds.Y += e.RowBounds.Height; // doesn't work
    }
}

And here's the problem. I thought I could move some kind of a bounding rectangle, but the only thing I see is RowBounds and that's read-only.

What are my options here?

John NoCookies
  • 1,041
  • 3
  • 17
  • 28
  • you can't do such a thing. If you do so, you have to add more 1 row to your `DataGridView` and **draw the cells** yourself at least starting from the threshold index. – King King Oct 09 '13 at 08:07
  • BTW, is your `Grid` data bound? You can insert some blank row at the `threshold index` and just draw that row in `CellPainting`. – King King Oct 09 '13 at 08:09
  • It's not bound. I thought about inserting empty rows and drawing the shapes over them, but that breaks row indices. – John NoCookies Oct 09 '13 at 08:16
  • Yes, that's what you have to accept, it's a work-around but because we don't have any straight way. – King King Oct 09 '13 at 08:18

0 Answers0