画除第一列之外的所有列,背景色画成白色。
public class DataGridColoredTextBoxColumn : DataGridTextBoxColumn
{
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)
{
try
{
backBrush = new LinearGradientBrush(bounds,
Color.White,
Color.White,
LinearGradientMode.BackwardDiagonal);
foreBrush = new SolidBrush(Color.Black);
}
catch (Exception) { /* empty catch */ }
finally
{
//judge whether the row is current selected, and paint to diffent color
//according to it,for whether selected is in higher priority
if (!this.DataGridTableStyle.DataGrid.IsSelected(rowNum))
// 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);