Hello,
I've this code:
Private Sub BuildDgStyle()
Dim dgStyle As New DataGridTableStyle
dgStyle.MappingName = Me.Tabella
Dim colCodice As New DataGridTextBoxColumn
colCodice.HeaderText = Me.HeaderCodice
colCodice.MappingName = Me.CampoCodice
If Me.MaxCodLenght > Me.HeaderCodice.Length Then
colCodice.Width = Me.MaxCodLenght + 5
Else
colCodice.Width = Me.HeaderCodice.Length + 5
End If
dgStyle.GridColumnStyles.Add(colCodice)
Dim colDescrizione As New DataGridTextBoxColumn
colDescrizione.HeaderText = Me.HeaderDescrizione
colDescrizione.MappingName = Me.CampoDescrizione
If Me.MaxDesLenght > Me.HeaderDescrizione.Length Then
colDescrizione.Width = Me.MaxDesLenght + 5
Else
colDescrizione.Width = Me.HeaderDescrizione.Length + 5
End If
dgStyle.GridColumnStyles.Add(colDescrizione)
Me.dgItems.TableStyles.Add(dgStyle)
End Sub
And I call that sub from Form_Load. The problem is that vb doesn't apply the style to my grid.
Where's the error

Can't apply a DataGridTableStyle to a Datagrid
jesse_j3000
J. Aldrin
Filipe Madurera
Then I would make sure you have your data set to the correct way.
Datasource = dataset
datamember = "tablename"
Also, why are you doing this the hard way you can do it via the designer alot better and faster. click the tablestyles property in the property browser and add a table style and then set the mapping then hit the grid column styles and then add your column styles.
Easy as pie.
Joe