Set watermark by code in the preview window

Hi, is there a way to change the watermark in the preview window, only by code, without passing through the EditWatermark window?
I've tried cycling the PreparedPages collection and set the watermark for all the pages but without success.
I've tried even cycling the ReportPages and regenerate the report with the RefreshReport method of the Preview window but without success.
Is there a way to realize this?
Thank you.

Comments

  • edited 5:32PM
    Hello,

    This code sets the watermark to all pages and refreshes a report:
          Watermark watermark = new Watermark();
          watermark.Enabled = true;
          watermark.Text = "TEST";
    
          ReportPage page = previewControl1.Report.PreparedPages.GetPage(previewControl1.PageNo - 1);
          ReportPage originalPage = page.OriginalComponent.OriginalComponent as ReportPage;
          originalPage.Watermark = watermark;
          previewControl1.RefreshReport();
    

Leave a Comment