Link to home
Start Free TrialLog in
Avatar of koken
koken

asked on

Grid companent...

Hi,

I need a grid companent that, it will be like excel grids.

I have to write formulas, make alignment, ability make cell border. these may be enough.

Do you know any companent like this?

Thanks.

Avatar of Mike Littlewood
Mike Littlewood
Flag of United Kingdom of Great Britain and Northern Ireland image

You might be able to embed an excel spreadsheet into your app if you use the OLEContainer component and user it just like excel.
Someone else might be able to give you code on how to do this or supply another alternative.
Avatar of koken
koken

ASKER

Thanks. But it must be without Excel.
ASKER CERTIFIED SOLUTION
Avatar of Dissaster
Dissaster

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You may also use TStringGrid ('Additional' tab) and draw contents of cells in onDrawCell event (this is really simple).
Here's a small example:

object StringGrid1: TStringGrid
  Left = 8
  Top = 24
  Width = 561
  Height = 369
  DefaultDrawing = False
  GridLineWidth = 0
  Options = [goEditing]
  TabOrder = 0
  OnDrawCell = StringGrid1DrawCell
end

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
var
  s : string;
begin
with StringGrid1, Canvas do begin
  s := Cells[aCol, aRow];
  Pen.Width := 1;
  if gdSelected in State then Pen.Color := $000000 else
  if gdFixed    in State then Pen.Color := $888888 else
  Pen.Color := $dddddd;
  if gdSelected in State then Brush.Color := $eeeeee else
  if gdFixed    in State then Brush.Color := $dddddd else
  Brush.Color := $ffffff;
  Rectangle(rect);
  Brush.Style := bsClear;
  with rect do
  if (length(s) > 0) and (s[1] = '=') then begin
    TextOut(left + (right - left - TextWidth('formula')) div 2, top + (bottom - top - TextHeight('formula')) div 2, 'formula');
  end else begin
    TextOut(left + (right - left - TextWidth(s)) div 2, top + (bottom - top - TextHeight(s)) div 2, s);
  end;
end;
end;

Notice that I've changed three settings for StringGrid1 to make it more "custom":
  DefaultDrawing = False
  GridLineWidth = 0
  Options = [goEditing] (removed )