[C#]DataGridView-CellPainting

  • 1443
  • 0

摘要:[C#]DataGridView-CellPainting


        private void dataGridView_ResultSpace_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            if (e.ColumnIndex == this.Column_ResultName.Index && e.RowIndex >= 0)
            {
                e.PaintBackground(e.CellBounds, true);
 
                TextRenderer.DrawText(e.Graphics, e.FormattedValue.ToString(),
 
                e.CellStyle.Font, e.CellBounds, e.CellStyle.ForeColor,
 
                 TextFormatFlags.RightToLeft | TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
 
                e.Handled = true;
 
            }
        }