0
votes

I have a very strange problem with Delphi Firemonkey TStringGrid on Android. It looks like that events on TStringGrid are triggered differently on windows and android platform. For example: in windows firemonkey application I have a string grid with a few columns. TStringGrid is set as read only. OnClick event I have the following code:

TStringGrid(Sender).Cells[TStringGrid(Sender).ColumnIndex,TStringGrid(Sender).Selected] := 'result';

Android application has exactley the same code OnClick event

TStringGrid(Sender).Cells[TStringGrid(Sender).ColumnIndex, TStringGrid(Sender).Selected] := 'result';

When I run windows application and click on string grid cell it becomes selected and then ‘result’ is written in the cell.

windows before click

enter image description here

windows after click

enter image description here

When I run android application and do click (tap) what happens is that ‘result’ is written in previously selected cell, and after that cell where I did click becomes selected.

android before click

enter image description here

android after click

enter image description here

I am not sure is this a bug in Firemonkey or expected behavior. Is there a way to overcome this?

2
Are you aware of the Embarcadero forums (the maker of delphi)? forums.embarcadero.com/forum.jspa?forumID=522greenapps
Yes, and I am forum member since 1999. Thank you very much for your suggestion but your comment doesn't help. Stackoverflow has much more available users that are willing to help.A.Z.

2 Answers

1
votes

TGrid is not a supported control on mobile so you should avoid using it. The best alternative is probably a TListBox with a custom style.

0
votes

It might a threading issue. But I'm not so sure you are using the best event handler. If you are trying to update the cell that is being selected, then I would advice you handle the TStringGrid.OnSelChanged event. This event is fired after cell selection has been changed.

Beware though... it is not strictly fired by mouse clicks (or finger taps). If you have some sort of keyboard attached to the Android device, or on a desktop platform, it will also fire when you use arrow keys and other means. I think you get what I mean... but then maybe that is just what you are looking for.