[Gambas-user] GridView_Column.Expand = True also needs AutoResize = True to work; expected behavior?

Benoît Minisini g4mba5 at gmail.com
Mon Feb 4 20:58:58 CET 2019


Le 04/02/2019 à 19:12, T Lee Davidson a écrit :
> On 2/4/19 9:24 AM, Fabien Bodard wrote:
>> Le dim. 3 févr. 2019 à 18:27, T Lee Davidson
>> <t.lee.davidson at gmail.com> a écrit :
>>>
>>> Gianluigi discovered that for GridView_Column.Expand = True to 
>>> actually have an effect, AutoResize also needs to be set = True.
>>> [https://lists.gambas-basic.org/pipermail/user/2019-February/066369.html] 
>>>
>>>
>>> Is this expected behavior, or a bug?
>>>
>>
>> I my fill I will vote for a bug. Because normally expand do not take
>> care about the content size. Then Autoresize give a size corresponding
>> to the content plus the padding and border.
>> If expand is selected  with  autoresize at true i think the correct
>> behavior will be to have a column than have a minimum size and just
>> complete the free space if it have.
>>
>> am I wrong ?
>>
> 
> I'm not sure, Fabien. I don't think GridView.AutoResize takes content 
> width into account.
> 
> I was thinking that AutoResize was just a shortcut for 
> GridView.Columns[GridView1.Columns.Max].Expand = True. But, that does 
> not appear to be the case. If the first and last columns are set Expand 
> = True, they both expand equally. That is, unless AutoResize is set to 
> False, then no columns expand.
> 
> If Benoît doesn't weight in on this soon, I'll probably just file a bug 
> report and let him reject it if it is expected behavior. Then I can 
> update the Wiki if needed.
> 
> 
> ___
> Lee
> 

Why don't you read the source code? It's the _GridView_Columns._Layout() 
method.

If The AutoResize property is not set, then the Expand has no effect, as 
no automatic resize occurs. Only explicit resize.

If AutoResize is set, then :

- If no visible column has the Expand property set, then the last column 
is expanded as if it has the Expand property set.

- Otherwise, the difference between the visible width and the width of 
static columns (with Expand not set) is shared between the expanded columns.

- If a column with Expand set has an explicit width, this explicit width 
becomes its minimum width and is taken into account during the previous 
share of remaining space.

Is the algorithm clear now?

-- 
Benoît Minisini


More information about the User mailing list