Dim i As Integer
Dim Tstyle As New DataGridTableStyle
Tstyle.MappingName = Gridtable.TableName
For i = 0 To Gridtable.Columns.Count - 1
Dim cs As New DataGridTextBoxColumn
cs.MappingName = Gridtable.Columns(i).ColumnName '指定数据源的列名
cs.HeaderText = Gridtable.Columns(i).ColumnName ' 列标头 'cs.TextBox.AutoSize = True
'Tstyle.PreferredColumnWidth = cs.TextBox.Width
If i = 2 Then cs.Format = "##,##0.00"
If i = 5 Or i = 2 Then cs.Width = 90
If i = 6 Then cs.Width = 175
Tstyle.GridColumnStyles.Add(cs)
Next