Page 1 of 1

gridview header height

Posted: Monday 29th October 2018 3:32pm
by bill-lancaster
Is there a way to determine the height of the header in gridview?

Re: gridview header height

Posted: Tuesday 30th October 2018 1:37pm
by bill-lancaster
I ask because, although the header height will usually be the same as row height, it possible for header height to be a multiple of row height.

Re: gridview header height

Posted: Tuesday 30th October 2018 4:12pm
by cogier
The only way I can find to set the header height is to set the font size.

Image

Try the following code: -
Public Sub Form_Open()
Dim GridView1 As GridView
Dim sText As String[] = ["Hello", "world!", "Charlie", "was", "here!"]
Dim siCount, siLoop As Short

With Me
  .Width = 900
  .Height = 200
  .Padding = 5
  .Arrangement = Arrange.Vertical
  .Text = "Gridview header height"
End With

GridView1 = New GridView(Me) As "GridView1"

With GridView1
  .Expand = True
  .Header = GridView.Horizontal
  .Font.Size = 40
  .Font.Bold = True
  .Columns.Count = 5
  .Rows.Count = 5
End With

Print GridView1.Rows.height ''Is there a way to determine the height of the header in gridview?

For siCount = 0 To sText.Max
  GridView1.Columns[siCount].Title = sText[siCount]
  GridView1.Columns[siCount].Alignment = Align.Center
Next

For siLoop = 0 To sText.Max
  GridView1.Rows[siLoop].Height = 20
  For siCount = 0 To sText.Max
    GridView1[siLoop, siCount].Text = sText[siCount]
    GridView1[siLoop, siCount].Font.Size = 12
    GridView1[siLoop, siCount].Font.Bold = False
  Next
Next

End
Is there a way to determine the height of the header in gridview?
If you add the following see line 25 above: -
Print GridView1.Rows.height
Do this before you lower the height of the rows (line 33).

Re: gridview header height

Posted: Thursday 1st November 2018 6:22pm
by bill-lancaster
That is amazing!
Thank you so much, I think this may be the only solution but such a complex solution to a simple matter
Regards