[Gambas-user] GridView.ClientWidth yields incorrect size on Form_Open
T Lee Davidson
t.lee.davidson at gmail.com
Sat Feb 2 20:53:08 CET 2019
On 2/1/19 10:07 PM, Denis Crowther wrote:
> I set the width to -1 which had no effect.
> Using expand, with or without the width = -1, worked.
Denis, the Expand property doesn't work for me. Could you provide a little code that shows how you made it work for you?
I am testing it thus (with AutoResize set to False):
[code]
Dim Headers As String[] = ["0123456789", "0123456789", "0123456789", "0123456789"]
GridView1.Rows.Count = 1
GridView1.Columns.Count = Headers.Count
GridView1.Columns[0].Expand = True
For i As Integer = 0 To Headers.Max
GridView1.Columns[i].Title = Headers[i]
GridView1[0, i].Text = String(30, "*")
Next
[/code]
I've tried setting Expand = True after the Column Titles are defined, but it makes no difference.
Charlie, thank you for that code. Setting the column width to -1 does automatically resize the column to fit the data. However,
I am trying to achieve the behavior that the Expand property is supposed to give: "Return or set if a GridView column
automatically expands to fit the GridView width." Meaning, as I understand it, similar to AutoResize but for a column other than
the last column.
I have actually accomplished this by capturing the sum of the column widths within the For loop and then resizing the first
column mathematically within the Arrange event. It would seem, though, that using the Expand property would be much simpler and
more sensible.
___
Lee
More information about the User
mailing list