Grid - Pre Sale Questions
Cell reference across multiple ProfGrid objects
Thread Starter: Joseph Chackungal Started: 6/18/2008 2:37 AM UTC
Replies: 3
Cell reference across multiple ProfGrid objects

Hello,

I am trialling ProfGrid v3.4.4.8 for a target application. I have the following two questions :

1. Is it possible to declare / create a ProfGrid object in runtime? I need to create multiple ProfGrid objects dynamically, to create a workbook type effect for the user.

2. I tried to reference Cells from one profgrid object to the other (ProfGrid1!A1), it works fine. But I want to know if it is possible to use some other name instead of the object name? Something like "Sheet1" or "Sales Data"? I wish to hide the underlying object names from the user.

Any guidance will be of great help.

Regards,

Re: Cell reference across multiple ProfGrid objects


Hello Everyone,

I have found the solution for my first problem. Runtime creation of ProfGrid object. Something was not correct with my installation. I just removed ProfGrid trial copy and then reinstalled it. No I can create as many ProfGrid objects I want on the fly.

Now, I need to know if I can refer Cells across these ProfGrid instances using some other names rather than using the object names.

Regards,

Re: Cell reference across multiple ProfGrid objects
Hello Joseph:

1. Is it possible to declare / create a ProfGrid object in runtime? I need
to create multiple ProfGrid objects dynamically, to create a workbook type
effect for the user.

Yes, certainly:

procedure TForm1.ToolButton1Click(Sender: TObject);
var
 Grid: TProfGrid;
begin
 Grid := TProfGrid.Create(Form1);
 Grid.Parent := Form1;
 Grid.Align := alClient;
end;

2. I tried to reference Cells from one profgrid object to the other
(ProfGrid1!A1), it works fine. But I want to know if it is possible to use
some other name instead of the object name? Something like "Sheet1" or
"Sales Data"? I wish to hide the underlying object names from the user.

No, it is not possible. But you can simply use some meaningful object names:

var Grid1, Grid2: TProfGrid;

procedure TForm1.ToolButton2Click(Sender: TObject);
begin
 Grid1 := TProfGrid.Create(Form1);
 Grid1.Parent := Form1;
 Grid1.Align := alClient;
 Grid1.Name := 'Sheet1';
 Grid1.SpreadsheetEnabled := True;
 Grid1.SpreadsheetHeaders := True;

 Grid2 := TProfGrid.Create(Form1);
 Grid2.Parent := Form1;
 Grid2.Align := alBottom;
 Grid2.Name := 'SalesData';
 Grid2.SpreadsheetEnabled := True;
 Grid2.SpreadsheetHeaders := True;

 Grid2.CellByName('A1').Formula := 'Sheet1!A1';
 Grid1.CellByName('B1').Formula := 'SalesData!B1';
end;


-Nicholas
Re: Cell reference across multiple ProfGrid objects

Hi Nicholas,

Thanks a lot for your reply.

I've been able to create multiple instances of Profgrid objects during runtime. I've successfully implemented a multisheet, workbook with Profgrid.

I've implemented a file format which embeds the objects name for the individual instances of ProfGrid and now I can save and restore them into a single file and each sheet can be referenced using the meaningful object names ( the object name appears on the tab for the user).

Thanks once again.