'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 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1