Design-time means

I've created simle report where one field is displayed. I need to change font(bold or not bold) for this field depending on other fields.
Is it possible at design-time ? Or I need to create objects dynamically at run-time ?

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 12:51PM
    at designtime set the memos font properties
    to change in runtime depending on an expression
    you can either write code in obp event of band or memo
    or use conditional highlight prop to add expression and set colors or font props.
    ;)
  • edited 12:51PM
    to gordk:

    Thanks. I tried following solution but it didn't work(no values actually displayed in report):

    TfrMemoView * m;

    report->LoadFromFile("e:\\4\test.frf");

    report->PrepareReport();

    TfrPage * page = new TfrPage(100,200,100,100,poLandscape);
    report->EMFPages->Add(page);
    report->EMFPages->ObjectsToPage(0);

    m = new TfrMemoView;

    m->SetBounds(220,120,200,16);

    m->FillColor = clRed;
    m->Font = this->Font;

    m->Name="MemeoTest";
    m->Script->Add("[FORMATDATETIME('dd mmmm yyyy',[DATE])]");

    report->EMFPages->Pages[0]->Page->Objects->Add(m);

    report->EMFPages->PageToObjects(0);

    report->ShowPreparedReport();
  • gordkgordk St.Catherines On. Canada.
    edited 12:51PM
    The code you show does not relate to the question you asked!
    What are you actually trying to do
    add a memo to a prepared report's emfpage(s) or add a memo to a report's designpage from external appcode?
    ;)
  • edited 12:51PM
    to gordk:

    You know. I need the simpliest way to resolve the problem: change font of memo at run-time. So please, help me with the code I wrote. ;)
  • gordkgordk St.Catherines On. Canada.
    edited 12:51PM
    I already gave you the way to change font's in a running report no external code is needed.
    however if you want to modify objects from external code you must get syntax correct and in properplaces.
    ie code to load report
    use findobject method to find the object on design page
    code to modify object
    code to show report.

    here is some sample delphi code to concantenate 2 reports into 1
    and add a memo to each emfpage with specific text and font properties.
    you will have to translate it to suit cbuilder.

    procedure TForm1.Button5Click(Sender: TObject);
    var
    i: integer;
    m : TfrMemoView;
    mystring : string;
    begin
    frReport1.LoadFromFile(WPath + '1.frf');
    frReport2.LoadFromFile(WPath + '3.frf');
    frReport1.PrepareReport;
    frReport2.PrepareReport;
    frReport1.EMFPages.AddFrom(frReport2);

    for i := 0 to frreport1.EMFPages.Count -1 do
    begin
    frReport1.EMFPages.ObjectsToPage(i);
    m:=TfrMemoView.Create;
    m.SetBounds(15,15,200,16);// create memo(l,t,w,h)in pixels
    m.FillColor := clYellow;
    mystring := 'Page '+inttostr(i+1)+' of '+inttostr(frreport1.EMFPages.Count)+ ' Pages';
    m.Memo.Add(''+ mystring +'');
    m.Name:='pageMemo';
    m.prop:= 'Courier New';
    m.prop := 8; // set font size
    m.Prop := 6; // set memo's font style. value is sum of frstyle constants
    // bold 2,ital 1, underline 4 strikeout 8
    m.Prop := clBlack; // any delphi color constant

    frreport1.EMFPages.Pages.Page.Objects.Add(m);
    frReport1.EMFPages.PageToObjects(i);
    end;
    frreport1.showpreparedreport;
    end;
    Also watch your apostrophes
    in most cases the sting value passed in needs extra to make up for the ide stripping.
    the bit of code where you are trying to add something to the memos script is useless, it wont display anything. The script of a memo is the code of it's onbeforeprint event.
    ;)
  • edited 12:51PM
    to gordk:

    Thanks a lot.
    I wrote the following code to display current date/time on the memo,but nothing was displayed.Do I use correct property('Script') and syntax ?

    m->Script->Add("[FORMATDATETIME('dd mmmm yyyy',[DATE])]");
  • gordkgordk St.Catherines On. Canada.
    edited 12:51PM
    You dont want it added to the script, you want it added to the memoviews memo
    this is the way it would appear in the memo of the memoview(textobject)
    in a design window, if you built the contents using the expression builder.

    [FORMATDATETIME('dd mmmm yyyy',[DATE])]

    since the ide strips the inner quotes when encountered it is easier to build the string in a variable then use the variable in the memoview's memo.add() method.
    much like building a filterstring for a table or query.
    from example this is where we added the value of mystring to the memoview's
    memo.
    m.Memo.Add(' '+ mystring +' ');
    ;)
  • edited 12:51PM
    to gordk:

    Sorry ... it doesn't work.
    When I write: m->Memo->Add("[DATE]") it displays [DATE] as text, not current date value.
  • gordkgordk St.Catherines On. Canada.
    edited 12:51PM
    ok since you are now seeing something in the memo,so work on the apostrophes
    you'll eventually get it right.
    you should see [Date] including brackets in the memo and when report is run the date will be subed for the the variable.
    ;)
  • edited 12:51PM
    to gordk:

    I tried single and double apostrophes. But it still displays [DATE] or '[DATE]' or something like this. Instead I need date value. In design-time everything is OK, but in run-time not ;)
  • gordkgordk St.Catherines On. Canada.
    edited 12:51PM
    Yes since you are adding to the emf page (finished out put) you must add the finished result of delphi calc not the expression
    m.memo.add (FORMATDATETIME('dd/mm/yyyy',DATE));
    if adding to a memo on design page which will then be processed you would add the expression
    '[formatdatetime('+''''+'dd/mm/yyyy'+''''+',[DATE])]'
    ;)

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.