Private Sub AddCustomDataTableStyles(ByVal dstData As DataSet, ByVal dgName As DataGrid)
'Clear the table styles for the datagrid
dgName.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
Select Case tcTextCol.MappingName()
Case "Address"
tcTextCol.Width() = 173
Case "CaseType"
tcTextCol.Width() = 75
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
dgName.TableStyles.Add(tsTableStyle)
End Sub