Search code examples
delphivcl

TStringGrid hide column


procedure TFormMain.CaseListMyShares(uri: String);
var
  i: Integer;
begin
  myShares := obAkasShareApiAdapter.UserShares(uri);
  MySharesGrid.RowCount:= Length(myShares) +1;
  MySharesGrid.AddCheckBoxColumn(0, false);
  MySharesGrid.AutoFitColumns;

  for i := 0 to Length(myShares) -1 do
  begin
    MySharesGrid.Cells[1, i+1]:= myShares[i].patientCase;
    MySharesGrid.Cells[2, i+1]:= myShares[i].sharedUser;
    MySharesGrid.Cells[3, i+1]:= myShares[i].creationDate;
    MySharesGrid.Cells[4, i+1]:= statusText[StrToInt(myShares[i].situation) -1];
  end;
end;

I want to create an invisible column to myself. I have to know row's identifier to make some operations with REST API. But end-user does not need to see this identifier on table. How can i create an invisible column ?

myShares[i].identifier which i want to hide on every row. Is that possible ? Using TAG or anything ?


Solution

  • To assign the identifier:

    MySharesGrid.Objects[0, i+1] := TObject(myShares[i].identifier)
    

    To access the identifier (e.g. OnClick):

    Integer(MySharesGrid.Objects[0, MySharesGrid.Row])