using System;
using System.Data;
using System.Windows.Forms;
using System.Drawing;
namespace ColoredRowTestApp
{
public class FormatEventArgs : EventArgs
{
public int RowNum ;
public Brush BackBrush;
public bool strikeThrough = false ;
public FormatEventArgs( int Rownum)
{
this.RowNum = Rownum ;
BackBrush = new SolidBrush(Color.White);
}
}
public delegate void CellPaint(object o, ref FormatEventArgs e);
/// <summary>
/// Summary description for FormattedTextBoxColumn.
/// </summary>
public class FormattedTextBoxColumn : DataGridTextBoxColumn
{
public CellPaint _handle ;
public CellPaint PaintHandle {
get
{
return _handle ;
}
set
{
_handle = value;
}
}
public FormattedTextBoxColumn()
{
//
// TODO: Add constructor logic here
//
_handle = null ;
}
protected override void Paint(Graphics g,Rectangle Bounds,CurrencyManager Source,int RowNum)
{
object data = (object) GetColumnValueAtRow(Source, RowNum);
String strData = data.ToString() ;
FormatEventArgs e = new FormatEventArgs(RowNum) ;
if( _handle != null)
_handle(new object(),ref e) ;
g.FillRectangle(e.BackBrush, Bounds.X, Bounds.Y, Bounds.Width, Bounds.Height);
System.Drawing.Font font = new Font(System.Drawing.FontFamily.GenericSansSerif , (float)8.25 );
g.DrawString( strData ,font ,Brushes.Black ,Bounds.X ,Bounds.Y );
}
protected override void Paint(Graphics g,Rectangle Bounds,CurrencyManager Source,int RowNum,bool AlignToRight)
{
object data = (object) GetColumnValueAtRow(Source, RowNum);
String strData = data.ToString() ;
FormatEventArgs e = new FormatEventArgs(RowNum) ;
if( _handle != null)
_handle(new object(),ref e) ;
g.FillRectangle(e.BackBrush, Bounds.X, Bounds.Y, Bounds.Width, Bounds.Height);
System.Drawing.Font font = new Font(System.Drawing.FontFamily.GenericSansSerif , (float)8.25 );
g.DrawString( strData ,font ,Brushes.Black ,Bounds.X ,Bounds.Y );
}
protected override void Paint(Graphics g,Rectangle Bounds,CurrencyManager Source,int RowNum, Brush BackBrush ,Brush ForeBrush ,bool AlignToRight)
{
Object data = ( Object ) GetColumnValueAtRow(Source, RowNum);
String strData ;
strData = data.ToString() ;
FormatEventArgs e = new FormatEventArgs(RowNum) ;
if( _handle != null)
_handle(new object(),ref e) ;
g.FillRectangle(e.BackBrush, Bounds.X, Bounds.Y, Bounds.Width, Bounds.Height);
FontStyle fs = FontStyle.Regular ;
if( e.strikeThrough == true )
{
fs = FontStyle.Strikeout ;
}
System.Drawing.Font font = new Font(System.Drawing.FontFamily.GenericSansSerif, (float)8.25 ,fs);
g.DrawString( strData ,font ,Brushes.Green ,Bounds.X ,Bounds.Y );
}
protected void Paint(Graphics g,Rectangle Bounds,CurrencyManager Source,int RowNum, Brush BackBrush ,Brush ForeBrush ,bool AlignToRight,bool changeColor)
{
object data = (object) GetColumnValueAtRow(Source, RowNum);
String strData = data.ToString() ;
FormatEventArgs e = new FormatEventArgs(RowNum) ;
if( _handle != null)
_handle(new object(),ref e) ;
g.FillRectangle(e.BackBrush, Bounds.X, Bounds.Y, Bounds.Width, Bounds.Height);
System.Drawing.Font font = new Font(System.Drawing.FontFamily.GenericSansSerif , (float)8.25 );
g.DrawString( strData ,font ,Brushes.Black ,Bounds.X ,Bounds.Y );
}
}
}