ProfGrid Quick Start

  • To put something in a cell, you use the Cells and Value properties, e.g.:
      In Delphi:
      ProfGrid1.Cells[0,0].Value := 'some text';
      ProfGrid1.Cells[
    0,1].Value := 123;
      ProfGrid1.Cells[
    0,2].Value := VarAsType(123.45, varDouble);
      ProfGrid1.Cells[
    0,3].Value := True;
      ProfGrid1.Cells[
    0,4].Value := False;
      ProfGrid1.Cells[
    1,0].Value := Date;
      ProfGrid1.Cells[
    1,1].Value := Time;
      ProfGrid1.Cells[
    1,2].Value := Now;
      ProfGrid1.Cells[
    1,3].Value := CompToCurrency(123);
      ProfGrid1.Cells[
    1,4].Value := 123.45;
      In C++Builder:
      ProfGrid1->Cells[0][0]->Value = "some text";
      ProfGrid1->Cells[
    0][1]->Value = 123;
      ProfGrid1->Cells[
    0][2]->Value = 123.45;
      ProfGrid1->Cells[
    0][3]->Value = true;
      ProfGrid1->Cells[
    0][4]->Value = false;
      ProfGrid1->Cells[
    1][0]->Value = Date();
      ProfGrid1->Cells[
    1][1]->Value = Time();
      ProfGrid1->Cells[
    1][2]->Value = Now();
      ProfGrid1->Cells[
    1][3]->Value = Currency(123);
      ProfGrid1->Cells[
    1][4]->Value = Currency(123.45);

  • To enable spreadsheet functionality, you set the SpreadsheetEnabled property to True. The property may be set both at design-time and at run-time. You may optionally display the spreadsheet headings using the SpreadsheetHeaders property.

  • To assign formulae programmatically, you use the Cells and Formula properties. The CellByName method may be also handy in some cases. E.g.:
      In Delphi:
      ProfGrid1.SpreadsheetHeaders := True;
      ProfGrid1.SpreadsheetEnabled := True;
      ProfGrid1.Cells[
    1,1].Formula := '2+2';
      ProfGrid1.Cells[
    1,2].Formula := 'A1+1';
      ProfGrid1.CellByName('
    A3').Formula := 'A2+1';
      In C++Builder:
      ProfGrid1->SpreadsheetHeaders = true;
      ProfGrid1->SpreadsheetEnabled = true;
      ProfGrid1->Cells[
    1][1]->Formula = "2+2";
      ProfGrid1->Cells[
    1][2]->Formula = "A1+1";
      ProfGrid1->CellByName(
    "A3")->Formula = "A2+1";

  • To attach an external control as your custom inplace editor, you place an invisible control on the form, and then use the OnGetEditControl event, e.g.
      In Delphi:
      procedure TForm1.ProfGrid1GetEditControl(Sender: TProfGrid; ACol,
        ARow: Integer; var AControl: TWinControl);
      begin
        AControl := ComboBox1
      end;
      In C++Builder:
      void __fastcall TForm1::ProfGrid1GetEditControl(TProfGrid *Sender,
            int ACol, int ARow, TWinControl *&AControl)
      {
        AControl = ComboBox1;
      }

  • To setup cell attributes column-wise, you use the Cols property and the appropriate properties of TProfGridColumn class, e.g.
      In Delphi:
      ProfGrid1.Cols[0].Color := clYellow;
      ProfGrid1.Cols[
    1].Font.Color := clRed;
      ProfGrid1.Cols[
    2].HorizontalAlignment := haCenter;
      ProfGrid1.Cols[
    3].CheckBox := True;
      ProfGrid1.Cols[
    4].Button := True;
      In C++Builder:
      ProfGrid1->Cols[0]->Color = clYellow;
      ProfGrid1->Cols[
    1]->Font->Color = clRed;
      ProfGrid1->Cols[
    2]->HorizontalAlignment = haCenter;
      ProfGrid1->Cols[
    3]->CheckBox = true;
      ProfGrid1->Cols[
    4]->Button = true;

  • To setup cell attributes cell-wise, you use the Cells property and the appropriate properties of TProfGridCell class, e.g.
      In Delphi:
      ProfGrid1.Cells[1,1].Color := clLime;
      ProfGrid1.Cells[
    1,2].Font.Style := [fsBold];
      ProfGrid1.Cells[
    1,3].CheckBox := True;
      ProfGrid1.Cells[
    1,3].CheckBoxChecked := True;
      ProfGrid1.Cells[
    1,4].InnerBorder.Color := clRed;
      In C++Builder:
      ProfGrid1->Cells[1][1]->Color = clLime;
      ProfGrid1->Cells[
    1][2]->Font->Style = TFontStyles() << fsBold;
      ProfGrid1->Cells[
    1][3]->CheckBox = true;
      ProfGrid1->Cells[
    1][3]->CheckBoxChecked = true;
      ProfGrid1->Cells[
    1][4]->InnerBorder->Color = clRed;