//color column 4 blue
if(e.Column == 1)
{
e.ForeBrush = Brushes.White;
e.BackBrush = Brushes.Blue;
}
//set font of some cells to bold
if( (e.Row + e.Column) % 5 == 0 )
e.TextFont = new Font(e.TextFont.Name, e.TextFont.Size, FontStyle.Bold);
//set textcolor of some cells to blue
if( (e.Row + e.Column) % 8 == 0 )
e.ForeBrush = Brushes.DodgerBlue;
//set font of some cells to bold, underline, italic with white text on green background
if( (e.Row + e.Column) % 9 == 0 )
{
e.TextFont = new Font(e.TextFont.Name, e.TextFont.Size, FontStyle.Bold | FontStyle.Italic | FontStyle.Underline);
e.ForeBrush = Brushes.White;
e.BackBrush = Brushes.Green;
}
public delegate void FormatCellEventHandler(object sender, DataGridFormatCellEventArgs e);
public class DataGridFormatCellEventArgs : EventArgs
{
private int _column;
private int _row;
private Font _font;
private Brush _backBrush;
private Brush _foreBrush;
private bool _useBaseClassDrawing;
public class DataGridFormattableTextBoxColumn : DataGridTextBoxColumn
{
//in your handler, set the EnableValue to true or false, depending upon the row & col
public event FormatCellEventHandler SetCellFormat;