ColumnHeadersVisible property failing

  • Thread starter Thread starter Rob Oldfield
  • Start date Start date
R

Rob Oldfield

I''ve got a datagrid on a windows form that I'm formatting using a custom
table style. Within the code that sets the style up I have
tsName.ColumnHeadersVisible=false.. but they are still displaying. Any
ideas why that might be?

Thanks
 
Yes. Everything else is working fine.

Private Sub SetupKeyTS()

Dim KeyTS As New DataGridTableStyle

KeyTS.MappingName = "Key"

KeyTS.GridLineStyle = DataGridLineStyle.None

KeyTS.RowHeadersVisible = False

KeyTS.ColumnHeadersVisible = False

KeyTS.AllowSorting = False



Dim aColumnTextColumn As DataGridTextBoxColumn = Nothing



aColumnTextColumn = New DataGridTextBoxColumn

aColumnTextColumn.MappingName = "C1"

aColumnTextColumn.NullText = ""

aColumnTextColumn.ReadOnly = True

aColumnTextColumn.Alignment = HorizontalAlignment.Center

aColumnTextColumn.Width = 40

KeyTS.GridColumnStyles.Add(aColumnTextColumn)



aColumnTextColumn = New DataGridTextBoxColumn

aColumnTextColumn.MappingName = "C2"

aColumnTextColumn.NullText = ""

aColumnTextColumn.ReadOnly = True

aColumnTextColumn.Alignment = HorizontalAlignment.Center

aColumnTextColumn.Width = 150

KeyTS.GridColumnStyles.Add(aColumnTextColumn)



KeyDG.TableStyles.Clear()

KeyDG.TableStyles.Add(KeyTS)

End Sub
 
OK. Figured it out. I hadn't noticed that there's a ColumnHeadersVisible
property on the datagrid control as well. I just set to false and
everything is fine.

(....though it beats me what the point of the property on the tablestyle
is....)
 
Yes, that is a bit confusing isn't it. Same with RowHeaders visible as well
as ReadOnly. You can set a grid to read only, but if you don't set the
column styles to read only as wel, then they're not.

Pete
 
Back
Top