private void Form1_Load(object sender, System.EventArgs e)
{
      this.dataGrid1.DataSource = SomeDataTable();
      AddCellFormattingColumnStyles(this.dataGrid1, new FormatCellEventHandler   (FormatGridCells));
}

解决方案 »

  1.   

    private void AddCellFormattingColumnStyles(DataGrid grid, FormatCellEventHandler handler)
    {
    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);}
      

  2.   

    关于DataGridFormattableTextBoxColumn和FormatCellEventHandler的实现
    请参考http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q792q
    中的5.63项