Grid - Pre Sale Questions
CellObject - a sample fragment please!
Thread Starter: Alfred Started: 5/18/2008 2:20 PM UTC
Replies: 2
CellObject - a sample fragment please!
Hello Nicholas,

Some time ago, I bought ProfDHTMLEdit and I liked it so that is why I am looking at ProfGrid - it is my third attempt to get a grid component that does what I want without busting a gut.

Like lots of others, when I try out a new component, I like to get something working quickly - usually demo examples are my starting point. You don't seem to offer any.

Next, I resort to Google and check out for fragments of code on the Internet and usenets. There is virtually nothing relevant out there. Not a word on experts-exchange.com which is quite an accomplishment. I am sure you have heard of the proverb "don't hide your light under a bushel"

Lastly, I search focusing on site:profgrid.newsgrouphosting.com or site:profgrid.com. In my search on the word CellObject, I only could find the "explanation" in your documentation. There is not even a fragment to illustrate its usage.

The following works:
  ProfGrid1.Cells[2,2].Button := true;
  ProfGrid1.Cells[2,2].Value := 'toto';

But his does not:
  ButtonX := TButton.Create(ProfGrid1);
  ButtonX.Caption := 'Hi there';
  ProfGrid1.Cells[2,3].CellObject := ButtonX;

Any ideas?

Re: CellObject - a sample fragment please!
Hello Alfred,

The CellObject property has no predefined meaning and is provided for the convenience of developers. The property can be used for storing any additional TObject with the cell.

(And if you want to create a button in the grid, simply use the Button property of TProfGridCell class).


-Nicholas
Re: CellObject - a sample fragment please!
Hello Nicholas,

Thanks for the quick reply. The trouble is that my grid has a large photo in an adjacent cell and if I do what you suggested, I get a huge button!

I tried placing a button on the grid and what is below but the button is invisible until one clicks twice slowly on it.

procedure TForm1.ProfGrid1GetEditControl(Sender: TProfGrid; ACol,
  ARow: Integer; var AControl: TWinControl);
begin
  if ACol = 2 then
    begin
    AControl := Button1;
    Button1.Visible := true;
    end;
end;