[Gambas-user] GridView.ClientWidth yields incorrect size on Form_Open
T Lee Davidson
t.lee.davidson at gmail.com
Sun Feb 3 00:24:12 CET 2019
On 2/2/19 5:05 PM, Gianluigi wrote:
> If with "Charlie" you're referring to me, also me can not get Expand to work.
> But I think you can easily replace it with Width = -1
Actually, no Gianluigi, I was not referring to you. I thought the code you first presented was directed toward someone else.
As far as I understand the two, GridView_Column.Expand cannot be easily replaced with .Width = -1. The latter causes the width
of the column to be resized according to the optimum width for the _data_ in the column. Whereas, .Expand works in relation to
the combined width of the other columns and the .ClientWidth.
I can achieve what I am wanting with:
[code]
Private iFixedColumnsWidth As Integer = 0
Public Sub Form_Open()
Dim Headers As String[] = ["0123456789", "0123456789", "0123456789", "0123456789"]
With GridView1
.AutoResize = False
.Header = GridView.Horizontal
End With
GridView1.Rows.Count = 1
GridView1.Columns.Count = Headers.Count
For i As Integer = 0 To Headers.Max
GridView1.Columns[i].Title = Headers[i]
iFixedColumnsWidth += GridView1.Columns[i].Width
Next
iFixedColumnsWidth -= GridView1.Columns[0].Width
End
Public Sub GridView1_Arrange()
GridView1.Columns[0].Width = (GridView1.ClientWidth - iFixedColumnsWidth)
End
[/code]
But not with the Expand property.
___
Lee
More information about the User
mailing list