protected void OnPaintRows(PaintEventArgs e)
{
int xPos = this.DisplayRectangleLeft;
int yPos = this.PseudoClientRect.Top;
if (this.HeaderStyle != ColumnHeaderStyle.None)
{
yPos += this.HeaderHeight;
}
bool wordWrapOn = this.EnableWordWrap;
Rectangle rowRect = new Rectangle(xPos, yPos, this.ColumnModel.TotalColumnWidth, this.RowHeight);
IRowFilter rowFilter = this.GetRowFilter();
for (int i = this.TopIndex; i < this.TableModel.Rows.Count; i++)
{
Row row = this.TableModel.Rows[i];
if (row == null)
{
continue;
}
if (row.Parent != null && !row.Parent.ExpandSubRows)
{
continue;
}
if (rowFilter != null && !rowFilter.CanShow(row))
{
continue;
}
rowRect.Height = row.Height;
if (wordWrapOn)
{
rowRect.Height = this.GetRenderedRowHeight(e.Graphics, row);
row.InternalHeight = rowRect.Height;
}
if (rowRect.IntersectsWith(e.ClipRectangle))
{
this.OnPaintRow(e, i, rowRect);
}
else if (rowRect.Top > e.ClipRectangle.Bottom)
{
break;
}
// move to the next row
rowRect.Y += rowRect.Height;
}
#region Set the background colour of the sorted column
if (this.IsValidColumn(this.lastSortedColumn))
{
if (rowRect.Y < this.PseudoClientRect.Bottom)
{
Rectangle columnRect = this.ColumnRect(this.lastSortedColumn);
columnRect.Y = rowRect.Y;
columnRect.Height = this.PseudoClientRect.Bottom - rowRect.Y;
if (columnRect.IntersectsWith(e.ClipRectangle))
{
columnRect.Intersect(e.ClipRectangle);
e.Graphics.SetClip(columnRect);
using (SolidBrush brush = new SolidBrush(this.SortedColumnBackColor))
{
e.Graphics.FillRectangle(brush, columnRect);
}
}
}
}
#endregion
}