Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Odd behavior with grid controls created at runtime
#1
Hi Alexandre,

I have an odd behavior with grid controls created at runtime.

In the attached example, I have two grids.
Grid1 is filled in the OnCreate of the Form, Grid2 is filled when the corresponding button is clicked.

When changing the controls in Grid1, clicking the Check Button shows the actual state(s) / value(s) of the Grid1 controls in Memo1.
But after changing and checking the controls in Grid2, Memo2 still shows the original state(s) / value(s) of the controls Grid2.

My questions:
1. Is this by design (I hope not)?
2. Am I doing something wrong?
3. Is this a bug and can it be fixed?

This not only applies to an IWGrid but also to an IWDBGrid.

I’m using Delphi 11.3 with IntraWeb 15.3.10.

Hope you can help me!

Cheers, Paul


Attached Files
.zip   GridControls.zip (Size: 92.28 KB / Downloads: 2)
Reply
#2
Hi Paul,

I'm working on it. I'll be back to you on this ASAP
Reply
#3
Hi Paul,

this modified example is working as it should. Please have a look:


.zip   GridControls.zip (Size: 54.84 KB / Downloads: 4)

The issue is: Whenever you create controls at runtime, always set the parent of the control. In the case of the grid, skipping this step works when rendering in a full post back (sync event) because of a "peculiarity" of the grid rendering mechanism when it has child controls. But it won't work in an async event. It won't work for any other parent either (i.e. if you create a IWCheckBox owned by the form and forget to make it the parent, it won't be visible, similar to what would happen in a desktop VCL application).

As a rule of thumb: whenever creating a control at runtime, first thing you do: set the parent.

If you don't mind I'd like to add this project of yours to our demo repository. It is a nice example on how to create such a grid  Smile

Cheers,
Reply
#4
Hi Aleandre,

Thank you for pointing this out, makes a lot of sense.
I can confirm the "odd behavior" is gone when setting the *parent* property.

And yes, by all means use this example in the demo repository.

Cheers!
Reply
#5
Great, thanks for that.

Here's the demo in our github repository:

https://github.com/Atozed/IntraWeb/tree/...idControls

Cheers
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)