FMXLivegrid locate record on form show

When I show my form I want the database to move to a specific record (currentrecord)

I have used this code after the database (in a data module dm) is opened in my onformshow event:

dm.mouldingstable.locate('id', currentrecord, []);

The problem is that while all other database-linked controls on the form show the correct record,  the FMXLivegrid has not scrolled to select the correct row.

However, if I put the dm.mouldingstable.locate('id', currentrecord, []); code in a button.onclick event on the form it works as expected.

How do I get the FMXLivegrid to show the current record in the database?

This used to work with a TStringgrid but not with an FMXLivegrid

I have found the solution.   I had set the form to auto-create and also created a dynamic instance of the form in my code.


I don't understand why this should have stopped it working but removing the dynamic form creation code fixed the problem

Hi,


The grid can only be access after the style is loaded. The OnApplyStyleLookup can be used to determine if the grid is loaded or not. Please note that this event can be called multiple times.