void PaintGridRowsColumnsOnlyParent(PaintEventArgs e, Pen gridPen)
{
if (this.TopIndex <= -1)
{
return;
}
int yline = this.CellDataRect.Y - 1;
int rowright = this.GetGridlineYMax(e);
int displayRectangleX = this.DisplayRectangleLeft;
ColumnCollection columns = this.ColumnModel.Columns;
RowCollection rows = this.TableModel.Rows;
// Need to draw each row grid at its correct height
for (int irow = this.TopIndex; irow < this.TableModel.Rows.Count; irow++)
{
if (yline > e.ClipRectangle.Bottom)
{
break;
}
if (yline >= this.CellDataRect.Top)
{
e.Graphics.DrawLine(gridPen, e.ClipRectangle.Left, yline, rowright, yline);
}
Row row = rows[irow];
yline += row.Height;
// Only draw columns on parent.
if (row.Parent != null)
{
continue;
}
int right = displayRectangleX;
// Draw columns
int columnCount = columns.Count;
for (int i = 0; i < columnCount; i++)
{
if (!columns[i].Visible)
{
continue;
}
right += columns[i].Width;
var flags = row.InternalGridLineFlags;
if (i != columnCount - 1 && !flags[i])
{
continue;
}
if (right >= e.ClipRectangle.Left && right <= e.ClipRectangle.Right)
{
e.Graphics.DrawLine(gridPen, right - 1, yline, right - 1, yline + row.Height);
}
}
}
// Now draw the final gridline under the last row (if visible)
// TODO Make this option selectable via a parameter?
if (yline < e.ClipRectangle.Bottom)
{
e.Graphics.DrawLine(gridPen, e.ClipRectangle.Left, yline, rowright, yline);
}
}