?
Solved

Delphi TStringGrid cells to store multiple objects

Posted on 2005-03-16
4
Medium Priority
?
2,941 Views
Last Modified: 2008-01-09
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.
0
Comment
Question by:engdmorr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 6

Expert Comment

by:pritaeas
ID: 13553792
You can create an object-list in StringGrid.Objects[ACol, ARow]. In this list you can then store your objects.
0
 

Author Comment

by:engdmorr
ID: 13554089
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
 
LVL 6

Accepted Solution

by:
pritaeas earned 500 total points
ID: 13554162
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
 

Author Comment

by:engdmorr
ID: 13555509
Never used TObjectList before, looks like an excellent feature of Delphi, thanks for the help, just what I was looking for.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question