简体   繁体   English

Delphi XE8 firemonkey移动应用程序中的StringGrid问题

[英]StringGrid issue in Delphi XE8 firemonkey mobile app

I'm using Delphi XE8 for developing mobile application and I'm facing some of the problem in TStringGrid. 我正在使用Delphi XE8开发移动应用程序,并且在TStringGrid中遇到了一些问题。

  1. I have written the following code in StringGridSelectCell event. 我在StringGridSelectCell事件中编写了以下代码。

Showmessage(StringGrid.Cells[0, ARow]); 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. 因此,我试图在OnClick事件中编写此消息。

    var iRowInd: Integer; var iRowInd:整数; begin iRowInd := StringGrid1.Selected; 开始iRowInd:= StringGrid1.Selected; ShowMessage(StringGrid.Cells[0, iRowInd]); 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. 此问题仅在android mobile中存在,而在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. 当我滚动网格时,它会触发onClick事件。 So, it is displaying the previously selected Row value. 因此,它将显示先前选择的行值。

Please provide me some solution. 请给我一些解决方案。 And Thanks in Advance. 并在此先感谢。

Let's do this with OnClick event: 让我们通过OnClick事件来做到这一点:

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) 属性TStringGrid.Selected将返回ROW ID(从零开始)

and

property TStringGrid.ColumnIndex will return COLUMN ID (Starting from Zero) 属性TStringGrid.ColumnIndex将返回COLUMN ID(从零开始)

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. 这样就形成了良好的应用程序GUI,并使其功能也适当。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM