Delphi TStringGrid cells to store multiple objects

Hi,

I am writing a program which has 12 records in it, each with different data content.  I want to use a grid (i.e. TStringGrid) to store the records in cells.

I want to be able to store say records R1, R3, R8 in cell 1, records R5, R3, R10 in cell 2 etc.  in other words I need the grid cell to be able to reference multiple objects.

Then, when I click on a cell a message dialogue will appear listing the objects stored in the particular cell clicked, with a printout of the record data.

I know I can use StringGrid.Objects[ACol, ARow] := Obj; to reference a single object but how can I store and access multiple objects for a cell?

I am new to Delphi so I need some help with this if anyone has any ideas.  I am open to any suggestions including 3rd party components.

Thanks in advance.
engdmorrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pritaeasSoftware EngineerCommented:
You can create an object-list in StringGrid.Objects[ACol, ARow]. In this list you can then store your objects.
0
engdmorrAuthor Commented:
So, I can use object Lists, but how to I separate the object list when I want to read an individual cell by clicking on it?  StringGrid1.Objects[ACol, ARow] only returns a TObject, I want to be able, when I click on the cell, to retrieve individual objects with its data, something like this.

if Objects.Items[i] is R1 then
  begin
    Memo1.lines.add('R1 is here');
   ...
  end;

Any ideas?
0
pritaeasSoftware EngineerCommented:
TObjectList itself is an object in a gridcell.
Create it like: StringGrid.Objects[ACol, ARow] := TObjectList.Create(True);

Then you can use:

if TObjectList(StringGrid.Objects[ACol, ARow])[i] is R1 then begin .. end;

TObjectList has a count property you can use i think.

See here for an example: http://www.festra.com/wwwboard/messages/1881.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
engdmorrAuthor Commented:
Never used TObjectList before, looks like an excellent feature of Delphi, thanks for the help, just what I was looking for.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.