Thanks for the help guys. I don't know why I had so much problems with this. At least I know of a bunch of ways on how NOT to create a customDataStyle. Anyway here is the solution and thanks again for the help. (You guys are the BEST!)
Create a CustomDataStyle procedure.
Run the procedure from the load event.
Everytime you requery your data - set
Datagrid.TableStyle(0).MappingName = ""
Datagrid.DataSource = ObjectDataSet
Datagrid.DataMember = "TableName"
Datagrid.TableStyle(0).MappingName = "TableName"
If you do not set the MappingName to "" before setting the DataSource you get an error. At least I did. Here is the CustomDataStyle procedure.
Private Sub CustomDataStyle()
Dim Ts1 as New DataGridTableStyle()
Ts1.MappingName = "Operator"
Dim grdColStyle as New DataGridTextBoxColumn()
grdColStyle.Width = 80
grdColStyle.MappingName = "Field1"
grdColStyle.HeaderText = "Field One"
Ts1.GridColumnStyles.Add(grdColStyle)
' Must set grdColStyle to New for every column, else every column uses the
' last column style that you set up
grdColStyle = New DataGridTextBoxColumn()
grdColStyle.Width = 80
grdColStyle.MappingName = "Field2"
grdColStyle.HeaderText = "Field Two"
Ts1.GridColumnStyles.Add(grdColStyle)
grdColStyle = New DataGridTextBoxColumn()
grdColStyle.Width = 80
grdColStyle.MappingName = "Field3"
grdColStyle.HeaderText = "Field Three"
Ts1.GridColumnStyles.Add(grdColStyle)
DataGrid.TableStyles.Add(Ts1)
End Sub
Randy Belcher
AFG Industries, Inc.