[Gambas-user] GridView.ClientWidth yields incorrect size on Form_Open

Denis Crowther denisc at exemail.com.au
Sun Feb 3 12:30:10 CET 2019


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 ]----


More information about the User mailing list