private void Form1_Load(object sender, System.EventArgs e)
{
this.dataGrid1.DataSource = SomeDataTable();
AddCellFormattingColumnStyles(this.dataGrid1, new FormatCellEventHandler (FormatGridCells));
}
{
this.dataGrid1.DataSource = SomeDataTable();
AddCellFormattingColumnStyles(this.dataGrid1, new FormatCellEventHandler (FormatGridCells));
}
{
DataGridTableStyle ts = new DataGridTableStyle();
DataTable dt = (DataTable) grid.DataSource; ts.MappingName = dt.TableName; for(int j = 0; j < dt.Columns.Count; ++j)
{
DataGridFormattableTextBoxColumn cs = new DataGridFormattableTextBoxColumn(j);
cs.MappingName = dt.Columns[j].ColumnName;
cs.HeaderText = dt.Columns[j].ColumnName;
cs.Alignment = System.Windows.Forms.HorizontalAlignment.Right;
cs.Width = 100;
cs.SetCellFormat += handler;
ts.GridColumnStyles.Add(cs);
} grid.TableStyles.Clear();
grid.TableStyles.Add(ts);}
请参考http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q792q
中的5.63项