Memo, Create new memo and setting from code

edited 3:32AM in FastReport 4.0
Using Fast Reports and Delphi 7. (I created all these problems from delphi 7 how do I apply at fast report)
trouble 1 :but how to create new object memo ? I tried this code below but not working
var
Page : TfrxReportPage;
Memo: TfrxMemoView;

begin
Page := TfrxReportPage(report.Pages[1]);
Page.Orientation := poLandscape;
Memo := TfrxMemoView(Page);
Memo.Create(nil);
Memo.Text := 'test';
where the error of my code ?

trouble 2 : how to make the settings manually from Delphi to memo (tfrxmemoview) / label the fast report
1.Top
2.Left
3.Line spacing
4.Width
5.Height

I expect a good example of how,thanks for the help of his suggestions

Comments

  • gpigpi
    edited 3:32AM
    See a Programmer's manual:
    1.12 Creating a report form from code
    As a rule, you will create most reports using the designer. Nevertheless, in some
    cases (for example, when the report???s form is unknown) it is necessary to create a report
    manually, from code.
    To create a report manually, one should perform the following steps in order:
    - clear the report component
    - add data sources
    - add the "Data" page
    - add report???s page
    - add bands on a page
    - set bands??? properties, and then connect them to the data
    - add objects on each band
    - set objects??? properties, and then connect them to the data
    Let us examine creation of a simple report of the ?«list?» type. Assume that we have
    the following components: frxReport1: TfrxReport and frxDBDataSet1: TfrxDBDataSet
    (the last one is connected to data from the DBDEMOS, the ?«Customer.db?» table). Our
    report will contain one page with the ?«Report Title?» and ?«Master Data?» bands. On the
    ?«Report Title?» band there will be an object with the "Hello FastReport!" text, and the
    ?«Master Data?» one will contain an object with a link to the "CustNo" field.
    Pascal:
    var
    DataPage: TfrxDataPage;
    Page: TfrxReportPage;
    Band: TfrxBand;
    DataBand: TfrxMasterData;
    Memo: TfrxMemoView;
    { clear a report }
    frxReport1.Clear;
    { add a dataset to the list of ones accessible for a report }
    frxReport1.DataSets.Add(frxDBDataSet1);
    { add the "Data" page }
    DataPage := TfrxDataPage.Create(frxReport1);
    { add a page }
    Page := TfrxReportPage.Create(frxReport1);
    { create a unique name }
    Page.CreateUniqueName;
    { set sizes of fields, paper and orientation by default }
    Page.SetDefaults;
    { modify paper???s orientation }
    Page.Orientation := poLandscape;
    { add a report title band}
    Band := TfrxReportTitle.Create(Page);
    Band.CreateUniqueName;
    { it is sufficient to set the ?«Top?» coordinate and height for a band }
    { both coordinates are in pixels }
    Band.Top := 0;
    Band.Height := 20;
    { add an object to the report title band }
    Memo := TfrxMemoView.Create(Band);
    Memo.CreateUniqueName;
    Memo.Text := 'Hello FastReport!';
    Memo.Height := 20;
    { this object will be stretched according to band???s width }
    Memo.Align := baWidth;
    { add the masterdata band }
    DataBand := TfrxMasterData.Create(Page);
    DataBand.CreateUniqueName;
    DataBand.DataSet := frxDBDataSet1;
    { the Top coordinate should be greater than the previously added band???s top + height}
    DataBand.Top := 100;
    DataBand.Height := 20;
    { add an object on master data }
    Memo := TfrxMemoView.Create(DataBand);
    Memo.CreateUniqueName;
    { connect to data }
    Memo.DataSet := frxDBDataSet1;
    Memo.DataField := 'CustNo';
    Memo.SetBounds(0, 0, 100, 20);
    { adjust the text to the right object???s margin }
    Memo.HAlign := haRight;
    { show the report }
    frxReport1.ShowReport;
    
  • edited May 2011
    thanks for the suggestion but I'm still not clear, so the need for example in delphi. i am tried 2x and both failed, one of for the code below :

    code 1:

    procedure TForm1.SettingMemoClick(Sender: TObject);
    var Memo: TfrxMemoView;
    begin
    Memo.CreateUniqueName;
    Memo.Text := 'Hello FastReport!';
    Memo.Height := 20;
    Memo.Align := baWidth;
    Memo.SetBounds(StrToInt(EditTopMargin.text), 0, 100, 20);
    frxReport1.ShowReport;

    end;

    or code 2:

    procedure TForm1.SettingMemoClick(Sender: TObject);
    var Memo: TfrxMemoView;
    begin
    Memo:= StrToInt(EditCOL_PAGE.text);//for Column page
    Memo:= StrToInt(EditRow_PAGE.text);//for maximum limit of rows
    Memo:= StrToInt(EditTopMemo.text);//for Top Memo
    Memo:= StrToInt(EditLeftMemo.text);//for Left Memo
    Memo:= StrToInt(EditWIDTH.text);//for width memo
    Memo:= StrToInt(EditHEIGHT.text);//for height memo
    Memo:= StrToInt(EditLine_Spacing.text);//for line spacing memo
    frxReport1.ShowReport;

    end;
  • gordkgordk St.Catherines On. Canada.
    edited 3:32AM
    in each of your procedures you need to have a report component reference.
    or if you are trying to add to an existing report you must have loaded the report into a tfrxreport component and then use findobject to get the object to which the new memoview will be added.
  • edited 3:32AM
    thanks for the gordk suggestion but I'm still not clear, so the need example in delphi...
  • gpigpi
    edited 3:32AM
    Use for example
    TfrxMemoView(frxReport1.FindObject('Memo1')).Left := 100;
  • edited 3:32AM
    if i want to set the Line Spacing to what the same for memo :
    TfrxMemoView (frxReport1.FindObject ('Memo1')). LineSpacing: = 100;
  • gpigpi
    edited 3:32AM
    wrote:
    if i want to set the Line Spacing to what the same for memo :
    TfrxMemoView (frxReport1.FindObject ('Memo1')). LineSpacing: = 100;
    Yes. Why you can't to try your code?

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.