protected override void Paint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
{
// Prepaint
DataGridViewPaintParts pre = DataGridViewPaintParts.Background | DataGridViewPaintParts.SelectionBackground;
pre = pre & paintParts;
base.Paint (graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, pre);
// Paint content
if (!IsInEditMode && (paintParts & DataGridViewPaintParts.ContentForeground) == DataGridViewPaintParts.ContentForeground) {
Color color = Selected ? cellStyle.SelectionForeColor : cellStyle.ForeColor;
TextFormatFlags flags = TextFormatFlags.EndEllipsis | TextFormatFlags.TextBoxControl;
flags |= AlignmentToFlags (cellStyle.Alignment);
Rectangle contentbounds = cellBounds;
contentbounds.Height -= 2;
contentbounds.Width -= 2;
// If we are top aligned, give ourselves some padding from the top
if (((int)cellStyle.Alignment & 7) > 0) {
contentbounds.Offset (0, 2);
contentbounds.Height -= 2;
}
if (formattedValue != null)
TextRenderer.DrawText (graphics, formattedValue.ToString (), cellStyle.Font, contentbounds, color, flags);
}
// Postpaint
DataGridViewPaintParts post = DataGridViewPaintParts.Border | DataGridViewPaintParts.Focus | DataGridViewPaintParts.ErrorIcon;
post = post & paintParts;
base.Paint (graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, post);
}