protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush foreBrush, bool alignToRight) { // the idea is to conditionally set the foreBrush and/or backbrush // depending upon some criteria on the cell value // Here, we color anything that begins with a letter higher than 'F' try{ object o = this.GetColumnValueAtRow(source, rowNum); if (o != null) { if (ColorDataGridCellEvent != null) { CellColorArgs a = new CellColorArgs(foreBrush, backBrush, rowNum, source.Position); ColorDataGridCellEvent(a); } } } catch (Exception) { //empty catch } finally { // make sure the base class gets called to do the drawing with // the possibly changed brushes base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight); } }
protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush foreBrush, bool alignToRight) { // the idea is to conditionally set the foreBrush and/or backbrush // depending upon some criteria on the cell value // Here, we color anything that begins with a letter higher than 'F' try{ object o = this.GetColumnValueAtRow(source, rowNum); if( o!= null) if (ColorDataGridCellEvent!=null) { CellColorArgs a = new CellColorArgs(foreBrush,backBrush,rowNum,source.Position); ColorDataGridCellEvent(a); } } catch(Exception) { //empty catch } finally { // make sure the base class gets called to do the drawing with // the possibly changed brushes base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight); } }