protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e)
{
bool doPaint = false;
if (e.ColumnIndex == CurrentCellAddress.X && e.RowIndex == CurrentCellAddress.Y)
{
e.CellStyle.SelectionBackColor = m_selCellBackColor;
e.CellStyle.SelectionForeColor = m_selCellForeColor;
if (!m_drawSelectedCellFocusRect)
{
DataGridViewPaintParts parts = e.PaintParts;
parts &= ~DataGridViewPaintParts.Focus;
// Grr. PaintParts is readonly. So I have to brute force it.
ReflectionHelper.SetField(e, "paintParts", parts);
doPaint = true;
}
}
base.OnCellPainting(e);
if (!e.Handled && doPaint)
{
e.Paint(e.ClipBounds, e.PaintParts);
e.Handled = true;
}
}