[Gambas-user] GridView.ClientWidth yields incorrect size on Form_Open
Gianluigi
bagonergi at gmail.com
Sun Feb 3 13:40:55 CET 2019
To be clearer:
It all depends on how AutoResize is set, for Expand to work fine, it must
be set to true.
Try this which it seems simpler:
'------------------------------
Public Sub Form_Open()
Dim Headers As String[] = ["0123456789", "0123456789", "0123456789",
"0123456789"]
With GridView1
.AutoResize = True ' <---------------!!!
.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]
GridView1[0, i].Text = String(30, "*")
Next
GridView1.Columns[0].Expand = True
End
'-------------------------------------------
Regards
Gianluigi
Il giorno dom 3 feb 2019 alle ore 12:32 Denis Crowther <
denisc at exemail.com.au> ha scritto:
> Hmmm, so that made me curious.. :-)
>
> So I threw a new GridView on a form and found that expand in either of
> these works as it should.
>
> I did notice that all the columns need to be sized at the same time.
>
> '---------------------------------------------
> Public Sub Form_Open()
>
> Dim iWide As Integer = 65
>
> With GridView1
> .Columns.Count = 3
> .Header = GridView.Horizontal
>
> ' .Columns[0].Width = iWide
> ' '-1 here makes the col really small
> ' '.Columns[1].Width = -1
> ' .Columns[1].Expand = True
> ' .Columns[2].Width = iWide
> End With
>
>
> For x As Integer = 1 To 10
> GridView1.Rows.Count += 1
> GridView1[x - 1, 0].Text = "test: " & x
> GridView1[x - 1, 1].Text = "rwrggrg rgrgreg reg erg reg last"
> GridView1[x - 1, 2].Text = Str(x)
> Next
>
> End
> '---------------------------------------------
> Public Sub GridView1_Arrange()
>
> Dim iWide As Integer = 65
> With GridView1
> .Columns[0].Width = iWide
> .Columns[1].Expand = True
> '-1 here resized the col to suit the data as expected
> '.Columns[1].Width = -1
> .Columns[2].Width = iWide
> End With
> End
> '---------------------------------------------
>
> Regards
> Denis
>
> On 3/2/19 11:03 am, T Lee Davidson wrote:
> > Thank you for that, Denis. But, even that didn't work for me.
> >
> > I can accomplish what I need by mathematically resizing the
> > variable-width column in relation to the combined widths of my
> > fixed-width columns.
> >
> >
> > ___
> > Lee
> >
> >
> > On 2/2/19 6:39 PM, Denis Crowther wrote:
> >> 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
> >
> > ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20190203/453cea0d/attachment.html>
More information about the User
mailing list