using System; using System.Data; using System.Text; using System.Windows.Forms; using System.ComponentModel; using System.Drawing; using System.IO; using System.Xml; namespace Common ... { DataGrid变色函数类_新(从本质上改属性)#region DataGrid变色函数类_新(从本质上改属性) //事件参数类 //自定义DataGridTextBoxColumn_noEdit(cTBC_1),不能编辑. public class CustomDataGridTextBoxColumn_noEdit : DataGridTextBoxColumn ...{ public event FormatCellEventHandler SetCellFormat; private int _col; public CustomDataGridTextBoxColumn_noEdit(int col) ...{ _col = col; } 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) ...{ DataGridFormatCellEventArgs e = new DataGridFormatCellEventArgs(rowNum, this._col, this.DataGridTableStyle.DataGrid.Font, backBrush, foreBrush); if(SetCellFormat != null) ...{ SetCellFormat(this, e); } if(e.UseBaseClassDrawing) base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight); else ...{ g.FillRectangle(e.BackBrush, bounds); g.DrawString(this.GetColumnValueAtRow(source, rowNum).ToString(), e.TextFont, e.ForeBrush, bounds.X, bounds.Y); } if(e.TextFont != this.DataGridTableStyle.DataGrid.Font) e.TextFont.Dispose(); } protected override void Edit(System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible) ...{ //取消编辑 //base.Edit(source, rowNum, bounds, readOnly, instantText, cellIsVisible); } } #endregion}