Hide a gridview header column without losing position of other header columns vb.net

I would like to hide the header for two columns on a gridview. However I would like the other column headers to remain in their original position not move across to where the hidden columns would have been.

The code I'm using to hide the headers is the following:

For colCount As Integer = 0 To 1
    gvProgressGrid.HeaderRow.Cells(colCount).Visible = False
Next

In the below example the headers should start at the column that contains the first set of blue cells.

Answers


Instead of toggling visibility, you can just set the column headers to empty strings and remove the border.

For colCount As Integer = 0 To 1
    gvProgressGrid.HeaderRow.Cells(colCount).Text = ""
    gvProgressGrid.HeaderRow.Cells(colCount).BorderStyle = BorderStyle.None
Next

If you want to retain the column header value, you could also just set the cell's foreground color equal to it's background color.

For colCount As Integer = 0 To 1
    gvProgressGrid.HeaderRow.Cells(colCount).ForeColor = gvProgressGrid.HeaderRow.Cells(colCount).BackColor
    gvProgressGrid.HeaderRow.Cells(colCount).BorderStyle = BorderStyle.None
Next

Need Your Help

Retrieve system properties via twiddle

properties jboss classpath twiddle

I am trying to retrieve system properties from JMX-console using twiddle in jboss4.3.

Show Image from URL in detailView after selection in tableView

swift uitableview uiimageview segue detailview

I have a tableView which display a list of traffic-cameras parsed from a XML file. When I select a cell, it sends the ImageURL, Roadname, Coordinates etc. via the prepareForSegue method.