![]() |
Odd behavior with grid controls created at runtime - Printable Version +- Atozed Forums (https://www.atozed.com/forums) +-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html) +--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html) +---- Forum: English (https://www.atozed.com/forums/forum-16.html) +----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html) +----- Thread: Odd behavior with grid controls created at runtime (/thread-3365.html) |
Odd behavior with grid controls created at runtime - PaulWeem - 07-10-2023 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 RE: Odd behavior with grid controls created at runtime - Alexandre Machado - 07-12-2023 Hi Paul, I'm working on it. I'll be back to you on this ASAP RE: Odd behavior with grid controls created at runtime - Alexandre Machado - 07-12-2023 Hi Paul, this modified example is working as it should. Please have a look: [attachment=607] 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 ![]() Cheers, RE: Odd behavior with grid controls created at runtime - PaulWeem - 07-12-2023 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! RE: Odd behavior with grid controls created at runtime - Alexandre Machado - 07-12-2023 Great, thanks for that. Here's the demo in our github repository: https://github.com/Atozed/IntraWeb/tree/master/15/Delphi/GridControls Cheers |