edit on preview form, but the print result is not same...

edited 10:34PM in FastReport .NET
i want to change the print value on the preview form.
        private void TxtObj_Click(object sender, EventArgs e)
        {
            TextObject curTextObject = sender as TextObject;
            if (curTextObject == null) return;

            curTextObject.InvokeEditor();
            curTextObject.SaveState();
            curTextObject.SaveStyle();
            InitModel.report.Preview.Refresh();
        }

when i close the editor form, the preview control display the right result. that's what i want.
but the print result don't change anymore...

>>

Comments

  • edited 10:34PM
    i known the frx designer on the preview form can make it,
    but it's too complex...
    what can i do?
    vision wrote: »
    i want to change the print value on the preview form.
            private void TxtObj_Click(object sender, EventArgs e)
            {
                TextObject curTextObject = sender as TextObject;
                if (curTextObject == null) return;
    
                curTextObject.InvokeEditor();
                curTextObject.SaveState();
                curTextObject.SaveStyle();
                InitModel.report.Preview.Refresh();
            }
    

    when i close the editor form, the preview control display the right result. that's what i want.
    but the print result don't change anymore...

    >>
  • Hello!

    The TextObject.InvokeEditor() method edits only a temporary in-memory copy of the object in the current preview—to ensure that the changes are included in the final printout and export, you must save the modified page back to PreparedPages using ModifyPage(...):

    private void TxtObj_Click (object sender, EventArgs e)
    {
    if (sender is TextObject curText && curText.InvokeEditor())
    {
    int pageIdx = report.Preview.PageNo - 1;
    var page = report.PreparedPages.GetPage(pageIdx);
    // If necessary, find the object on the page and update its Text
    report.PreparedPages.ModifyPage(pageIdx, page);
    report.Preview.Refresh();
    }
    }
    

    After calling ModifyPage(...), the modified text is saved both when printing and when exporting to PDF without launching the full designer.

This discussion has been closed.