2/. It took some experimentation, but I think you will find that the cells will now auto adjust.
3/. The .Font.Underline works for me.
Here is the modified code: -
' Gambas class file
Public MyPanel As Panel 'Something for later ...
Public MyGrid As GridView
Public MyButton As Button
Public Text$ As String
Public Edit$ As New String[20]
Public Number As Integer
Public Sub Form_Open()
With Me
.Center
.Height = 500
.Width = 400
.Arrangement = Arrange.Vertical
.Padding = 50
End With
With MyPanel = New Panel(Me) As "MyPanel"
'Trying to use a panel and placing MyGrid on it
'to create a border around MyGrid. Didn't work ...
.Border = Border.Etched ''***************************
.Expand = True
.padding = 2
.Arrangement = Arrange.Fill ''***************************
.Background = &H00FF00FF&
End With
With MyGrid = New GridView(MyPanel) As "MyGrid" 'New GridView(Me.MyPanel) ???
.rows.Count = 20
.columns.Count = 1
.ScrollBar = False
.NoTabFocus = True
.expand = True
.Background = &HFFFFFFFF&
.border = True
.Grid = False
.Padding = 6
End With
With MyButton = New Button(Me) As "MyButton"
.NoTabFocus = True
.width = 60
.height = 20
.text = "Click to activate grid"
End With
End
Public Sub MyButton_click()
With MyGrid
Number = 0
.[0, 0].Alignment = Align.Center 'This takes care of the 'no center' HTML problem
.[0, 0].Font = Font["Arial,16,Bold"]
.[0, 0].RichText = GetText() 'RichText can be used, even if there's no HTML markup
.Rows[0].Height = -1 ''***************************
Number = 1
.[1, 0].Font = Font["Comic sans,8"]
.[1, 0].WordWrap = True
.[1, 0].RichText = GetText()
.Rows[1].Height = -1 ''***************************
Number = 2
.[2, 0].Font = Font["Arial,12"]
.[2, 0].Font.Underline = True 'This doesn't seem to work, but doesn't produce an error either
.[2, 0].WordWrap = True
.[2, 0].RichText = GetText()
.Rows[2].Height = -1 ''***************************
Number = 3
.[3, 0].Font = Font["Times,9"]
.[3, 0].WordWrap = True
.[3, 0].RichText = GetText()
.Rows[3].Height = -1 ''***************************
End With
End
Public Sub GetText() As String
'The data to be used in the GridView will be read from an external file.
Edit$[0] = "Welcome"
Edit$[1] = "<b><i>This line uses HTML Bold & Italic</i></b><br>and switches them of in the next one</br>"
Edit$[2] = "Lorem ipsum ... Yeah, I know ..."
Edit$[3] = "<i>And now let's see what happens with some very long text.</i><br>" "</br><br><b>WordWrap does work, but it would be ideal if the row's height could change with it.</b></br>" "</br><br><b>WordWrap does work, but it would be ideal if the row's height could change with it.</b></br>" "</br><br><b>WordWrap does work, but it would be ideal if the row's height could change with it.</b></br>"
Text$ = Edit$[Number]
Return Text$
End
Public Sub MyGrid_Click()
MyGrid.Grid = Not MyGrid.Grid
' If MyGrid.Grid = False Then
' MyGrid.Grid = True
' Else
' MyGrid.Grid = False
' End If
End