. CellPainting, , Graphics Graphics . Graphics DataGridView.GetGraphics(), .
, , , , .
CellPainting , , :
e.Paint(e.ClipBounds, DataGridViewPaintParts.All);
, , - 2 - . , , .
MeasureString Graphics, . Graphics, , Graphics , . DataGridView.GetCellDisplayRectangle, :
CellRectangle = Cell.DataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
HighLightedRect = new Rectangle((Point)SizeBeforeHighLight, HighLightedSize);
HighLightedRect.Location = new Point(CellRectangle.Location.X + SizeBeforeHighLight.Width, CellRectangle.Location.Y + Cell.ContentBounds.Top);
FillRectangle DrawString Graphics:
g.FillRectangle(new SolidBrush(Color.Black), HighLightedRect);
g.DrawString(HighlighetText, dgvGrid.Font, new SolidBrush(Color.White), HighLightedRect.Location);
g.Flush();
, , e true, :
e.Handled = true;
, : , , , , , , .