我的代码如下:
DataTable dt;
DataColumn dc;
 dt = new DataTable("Customers");//CustomerID column
dc = dt.Columns.Add( "CustomerID", System.Type.GetType( "System.Int32" ) );
dc.Caption = "编号";
dc.Unique = true;
    
//CustomerName column
dc = dt.Columns.Add( "CustomerName", System.Type.GetType( "System.String" ) );
dc.Caption = "姓名";//CreditLimit
dc = dt.Columns.Add( "CreditLimit", System.Type.GetType( "System.Double" ) );
 dc.DefaultValue = 0;
 dc.Caption = "信誉额"; dt.Rows.Add( new object[] {1, "Jonathan", 23.44} );
 dt.Rows.Add( new object[] {2, "Bill",     56.87} );DataGrid dataGrid1=new DataGrid()
dataGrid1.DataSource =dt;我想让dataGrid1显示编号、姓名、信誉额,请问各位高手如何设置?

解决方案 »

  1.   

    你可以在dataGrid的属性栏里添加,在属性栏里找到TableStyle,电击(Collection),在对话框里添加一个dataGridTableStyle,再在右边找到它的属性GridColumnStyle,在它里面添加Caption , 具体的你试一下就明白了
      

  2.   

    属性栏里面有个TABLESTYLE,你进去自然就知道了,可以修改标签,格式,等
      

  3.   

    this.dataGrid1.TableStyles.Add(new DataGridTableStyle());
    this.dataGrid1.TableStyles[0].GridColumnStyles[0].HeaderText="编号";
    this.dataGrid1.TableStyles[0].GridColumnStyles[1].HeaderText="姓名";
    this.dataGrid1.TableStyles[0].GridColumnStyles[2].HeaderText="信誉额";