Private Sub AddCustomDataTableStyles(ByVal dstData As DataSet)
'Clear the table styles for the datagrid
DataGrid1.TableStyles.Clear()
'Declare local variables
Dim tsTableStyle As New DataGridTableStyle
Dim tcTextCol As DataGridTextBoxColumn
Dim intCounter As Integer
'Map the table style to the table in the dataset
tsTableStyle.MappingName = dstData.Tables(0).TableName()
'Add textbox column style for each column in the dataset
For intCounter = 0 To dstData.Tables(0).Columns.Count() - 1
'Reinstantiate the text box column and set mappings and attributes
tcTextCol = New DataGridTextBoxColumn
tcTextCol.MappingName = dstData.Tables(0).Columns.Item(intCounter).ColumnName
tcTextCol.HeaderText = dstData.Tables(0).Columns.Item(intCounter).ColumnName
'Set column size based on name
Select Case tcTextCol.MappingName()
Case "SomeColumnName"
tcTextCol.Width() = 100
Case Else
tcTextCol.Width() = 50
End Select
'Add the column to the table style
tsTableStyle.GridColumnStyles.Add(tcTextCol)
Next
'Add the table styles to the datagrid
DataGrid1.TableStyles.Add(tsTableStyle)
End Sub