[Gambas-user] GridView.ClientWidth yields incorrect size on Form_Open
Denis Crowther
denisc at exemail.com.au
Sun Feb 3 00:39:19 CET 2019
Sure Lee,
Copied straight from a working program.
I 'think' the trick is to use the Arrange event.
Using -1 didn't work for me in the arrange event,
I haven't tested it anywhere else yet.
Public Sub tblTest_Arrange()
With tblTest
.Columns[0].Width = 0
'.Columns[1].Width = 150
.Columns[1].Expand = True
.Columns[2].Width = 50
End With
End
Regards
Denis
On 3/2/19 6:53 am, T Lee Davidson wrote:
> 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
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
More information about the User
mailing list