0
votes

I'm using Delphi XE8 for developing mobile application and I'm facing some of the problem in TStringGrid.

  1. I have written the following code in StringGridSelectCell event.

Showmessage(StringGrid.Cells[0, ARow]);

And this shows the proper value of the selected row at the first time. But when I have tried to click again the selected row, this event is not getting fired. And I cant able to unselect the particular row.

  1. So, I have tried to write this message in OnClick event.

    var iRowInd: Integer; begin iRowInd := StringGrid1.Selected; ShowMessage(StringGrid.Cells[0, iRowInd]); end;

And this is not working at the first time of the click and when I clicked for the second time it works properly. This issue is only in android mobile and not in Windows.

  1. Later, I have kept both the event code and then also I faced another issue. When I'm scrolling the Grid, it is firing the onClick event. So, it is displaying the previously selected Row value.

Please provide me some solution. And Thanks in Advance.

2

2 Answers

1
votes

Let's do this with OnClick event:

procedure TfmMain.StringGrid1Click(Sender: TObject);
begin
  Caption := 'Selected ROW ID: ' + StringGrid1.Selected.ToString + '. Selected COLUMN ID: ' + StringGrid1.ColumnIndex.ToString + '. Action at: ' + DateTimeToStr(Now);
end;

property TStringGrid.Selected will return ROW ID (Starting from Zero)

and

property TStringGrid.ColumnIndex will return COLUMN ID (Starting from Zero)

0
votes

As of now, I have used the Material Design in the Form. And first the user needs to Select the Grid. Then, the user needs to click the button and after that I'm proceeding my logic. This makes the good application GUI and makes the functionality also proper.