TADVStringGrid - Tag/ID for each row?

We use TCollections A lot. Big and small ....

We use TADVStringGrid as A prepresentation of the data in these TCollections.

Like I could have 1000 items in the collection with 50 properties to it, but depending on user input only 234 of those will show in A grid and maybe only 10 of those properties will be columns shown.

In the grid, 234 rows, 10 columns wide.

The user can sort and filter.

I can't find a way, but it would be nice if each Grid Row could have an ID.. TAG ... something that follows that row. So if you sort/filter/ect that ID/TAG follows each rows state.

Idx := Grid.Rows[Grid.RealRowIndex].ID;

MyCollection.Items[Idx].Something := 'blah';

Its been asked by other coworkers about such ability to quickly link rows to collection item indexes without need of hidden columns to store it and such.

I guess could subclass this all and expand on it myself? but rather have something built into TADVStringGrid to handle this.

Just trying to figure a better way to link TCollections to A TADVStringGrid and have a best method of going between the two for read/setting data as needed.

With a cell you can associate an object via grid.Objects[col,row]: TObject, so either you can cast can integer identifier as TObject or create a TObject and store it via cell.Objects[col,row]

This is a quick general request. Has anyone used TObjects with Grid cells? If so, could you share some example code? I'm (embarrassingly) not very expert on how to create/use objects. Particularly confused about how to properly free up memory (e.g. when number of grid rows changes). Thanks in advance for any advice!

You can set an integer to a cell via

grid.Objects[col,row] := TObject(10);

When you change (decrease) grid.RowCount yourself in code, free possible objects used via grid.ClearRect() for the rectangle of cells that will disappear with this change in RowCount (if the change of RowCount will be final)