protected virtual Rectangle CalculateAlignedRectangle(Graphics g, Rectangle r)
{
if (this.Column == null || this.Column.TextAlign == HorizontalAlignment.Left)
return r;
int width = this.CalculateCheckBoxWidth(g);
width += this.CalculateImageWidth(g, this.GetImageSelector());
width += this.CalculateTextWidth(g, this.GetText());
// If the combined width is greater than the whole cell,
// we just use the cell itself
if (width >= r.Width)
return r;
return this.AlignRectangle(r, new Rectangle(0, 0, width, r.Height));
}