[英]How to set text alignment for a specific column in firemonkey TGrid/TStringGrid?
[英]How to set 'selected' property of TGrid to -1
我正在使用FMX.Grid.TGrid
,用戶可以在其中選擇完整的行。 在某些情況下,我想重置此選擇。 如果我使用grid.selected = -1
或grid.selectRow(-1)
進行選擇,則選擇將從網格中刪除,但grid.selected
設置為“ 0”(在TCustomGrid.SelectCell
),這是第一行。
如何重置選擇,以便grid.selected
屬性為“ -1”?
我檢查了FMX庫的代碼,並做了微小的類幫助程序,該程序使您可以直接訪問作為選定行存儲值的私有屬性。 在Delphi XE8上測試。 即使您啟用了“ AlwaysShowSelection”選項,此代碼也將正常工作。
TMyG = class helper for TCustomGrid
public
procedure DoSomethingStrange;
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.btnReadSelectionClick(Sender: TObject);
begin
Caption := Grid1.Selected.ToString;
end;
procedure TForm1.btnResetSelectionClick(Sender: TObject);
begin
Grid1.DoSomethingStrange;
end;
{ TMyG }
procedure TMyG.DoSomethingStrange;
begin
Self.FSelected := -1;
Self.UpdateSelection;
end;
如果您的目的不是在網格中顯示選定的行,則可以通過將焦點放在另一個組件上來使其散焦。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.