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的初始化类 public class InitCustomDataGridTextBoxColumn ...{ public void InitCell(DataGrid dG,FormatCellEventHandler Handle,CurrencyManager cM,DataGridTableStyle dGS,int col_no,string col_id,string col_name,int col_len,string col_align,string col_fmt,string read_only) ...{ CustomDataGridTextBoxColumn cTBC_1 = new CustomDataGridTextBoxColumn(col_no); cTBC_1.MappingName = col_id; cTBC_1.HeaderText = col_name; cTBC_1.Width = 7*col_len; if(col_align=="r") cTBC_1.Alignment = HorizontalAlignment.Right; else if(col_align=="c") cTBC_1.Alignment = HorizontalAlignment.Center; if(col_fmt.Trim()!="") cTBC_1.Format = col_fmt; if(read_only=="true") cTBC_1.ReadOnly = true; else cTBC_1.ReadOnly = false; cTBC_1.NullText = ""; cTBC_1.SetCellFormat += Handle; dGS.GridColumnStyles.Add(cTBC_1); } public void InitCell_noEdit(DataGrid dG,FormatCellEventHandler Handle,CurrencyManager cM,DataGridTableStyle dGS,int col_no,string col_id,string col_name,int col_len,string col_align,string col_fmt,string read_only) ...{ CustomDataGridTextBoxColumn_noEdit cTBC_1 = new CustomDataGridTextBoxColumn_noEdit(col_no); cTBC_1.MappingName = col_id; cTBC_1.HeaderText = col_name; cTBC_1.Width = 7*col_len; if(col_align=="r") cTBC_1.Alignment = HorizontalAlignment.Right; else if(col_align=="c") cTBC_1.Alignment = HorizontalAlignment.Center; if(col_fmt.Trim()!="") cTBC_1.Format = col_fmt; if(read_only=="true") cTBC_1.ReadOnly = true; else cTBC_1.ReadOnly = false; cTBC_1.NullText = ""; cTBC_1.SetCellFormat += Handle; dGS.GridColumnStyles.Add(cTBC_1); } } #endregion}