Nevermore
Nevermore

Reputation: 1743

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 ?

Upvotes: 0

Views: 3107

Answers (2)

Jon
Jon

Reputation: 850

To answer the question, assign its ColWidths to -1, thusly:

StringGrid1.ColWidths[4] := -1;

You can show it again by setting that back to a positive value.

This is not about using a StringGrid to store data, but for the User Interface to show/hide columns - like a Collapse speedbutton in the title, with a corresponding Show All button to restore it.

Upvotes: 2

MaGiC
MaGiC

Reputation: 311

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])

Upvotes: 1

Related Questions