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

Rolf-Werner Eilert rwe-sse at osnanet.de
Fri Feb 1 09:51:12 CET 2019


Am 01.02.19 um 00:17 schrieb Benoît Minisini:
> Le 01/02/2019 à 00:11, T Lee Davidson a écrit :
>> I am trying to resize a column other than the last column to take up 
>> the remaining available client space. But, I don't get a correct value 
>> for GridView.ClientWidth until the Form_Show event. Per the subject 
>> line, is this expected behavior or a bug?
>>
> 
> It's expected, as the form and its contents is often arranged after the 
> Open event has been emitted.
> 
> I suggest using use the Arrange (or rarely the BeforeArrange) event of 
> some container including your gridview to do what you want to do.
> 
> Regards,
> 

Same problem here in the last months in two different projects.

Something must call a Refresh of the GridView before all values are 
finally returned correctly. It is not only Width, it is also column X 
values etc.

Example 1: In a calendar project there is sometimes a little dialog 
which appears over the main form with the GridView, and the GridView 
stays uncomplete first. When the user clicks off the dialog, the 
GridView will be refreshed and appears ok from then on. But when the 
dialog does not appear, the GridView will only complete when some 
refresh is forced, e. g. when the user chooses another week and then 
comes back.

Example 2: In a school schedule program, there is a Baines line. On 
start, it always receives a column X value of 0, so the line will always 
start on Monday.

Up to now I found a workaround by introducing a Timer which starts 
Enabled, e. g. every second. In its event I call either GridView.Refresh 
or the function which cares for the GridView and its contents, and after 
ticking once or twice, the GridView reacts normally and the Timer can be 
disabled.

Now that I read your hint to use Arrange, of course I tried it, but it 
has no effect.

Regards
Rolf


More information about the User mailing list