Is it possible to hide components from delphi code

JonJon
edited 9:05PM in FastReport 4.0
Is it possible to hide components (e.g. check the value of a data memo and hide if value is zero) using code in delphi. ?

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 9:05PM
    yes but awkward easier to do it in the internal obp event of the memo or the band containing the memo.
  • JonJon
    edited 9:05PM
    gordk wrote: »
    yes but awkward easier to do it in the internal obp event of the memo or the band containing the memo.

    Yes I used the report events in FR2, but the FR4 version that comes with XE5 does not give access to events in the report.

    It returns Null where ever I seem check the value of the data using
    m = frxReport.FindObject('frxMemoName') As TfrxMemoView;
    v = TfrxMemoView(m).DataSet.Value[TfrxMemoView(m).DataField];

    And just returns the field (eg [frxdbDataset.'fieldname']) using
    m = frxReport.FindObject('frxMemoName') As TfrxMemoView;
    m.Text

    Can you tell me how it is done in delphi code?
  • gordkgordk St.Catherines On. Canada.
    edited 9:05PM
    create a variable in the report connect it to the data field
    you can get its value in delphi.
    assuming the memo is on masterdata1
    use the obp event of the report in delphi
    if sender.name = 'Masterdata1'
    then
    if frxreport1.variables.value = whatever your testing for
    then
    m = frxReport.FindObject('frxMemoName') As TfrxMemoView;
    m.visible :=false;
  • JonJon
    edited 9:05PM
    gordk wrote: »
    create a variable in the report connect it to the data field
    you can get its value in delphi.
    assuming the memo is on masterdata1
    use the obp event of the report in delphi
    if sender.name = 'Masterdata1'
    then
    if frxreport1.variables.value = whatever your testing for
    then
    m = frxReport.FindObject('frxMemoName') As TfrxMemoView;
    m.visible :=false;

    Thank you for your help. When the OnBeforePrint code runs I get an 'Invalid variant operation' message at the line with if frxreport1.variables.value = 0 ?

    To test I commented out obp code, added the variable into a memo on the data band and it shows the data so variable appears to be OK. So I then edited above line to use a system variable frxreport1.variables.value and got the same message.

    I must be missing something subtle here, but I can't see what?
  • gpigpi
    edited 9:05PM
    Try to use frxreport1.Variables.variables or frxReport1.Calc('<variablename>')
  • JonJon
    edited 9:05PM
    gpi wrote: »
    Try to use frxreport1.Variables.variables or frxReport1.Calc('<variablename>')

    Thanks for your help. I get the same problem though.
  • JonJon
    edited 9:05PM
    OK I have found the solution. This is such a basis requirement and not in any of the help documents, so here is the solution for anyone else who needs it.

    As well as setting the datafield in the Text of the TfrxMemoView, the DataSet and DataField must also be set in the Properties of TfrxMemoView, or the values are not visible from the code.

    Delphi OnBeforePrint Code:

    If Sender.Name = 'MasterData1' then begin
    m := frxReport1.FindObject('Memo1') As TfrxMemoView;
    v := TfrxMemoView(m).DataSet.Value[TfrxmemoView(m).DataField];
    if v = 0 then
    m.Visible := false
    else
    m.Visible := true;
    end

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.