Reputation: 292
I have created a Section Report using ActiveReports 9 Designer. I need to set watermark based on a flag. If flag is ON, watermark should be set for that particular page. If flag is OFF, watermark should be nothing.
I'm having the flag textbox and watermark image in group header. So I thought of toggling the watermark in GROUPHEADER1_BeforePrint of Report script.
Sub GroupHeader1_BeforePrint
if(TxtFlg.text = "1") Then
rpt.Watermark = imgWaterMark.Image
else
rpt.Watermark = nothing
End If
End Sub
My problem is - the first page is skipping and it is continuing from next page. The 1st page watermark is displayed in 2nd page, 2nd page watermark is displayed in 3rd page and so on. Why is it displaying like this ?
Can anyone please help me . Thanks in advance .
Upvotes: 2
Views: 1812
Reputation: 847
This is the design behavior. The Watermark
property is for the entire report and gets rendered before any other section gets rendered. So when you're setting the watermark in the GroupHeader_Format
event, the watermark for that page has already been printed and hence can't be changed. Because of this the watermark is printed on the next page. Now, to solve your problem to render the Watermark on the first page, you can set it in the ReportStart
event. For other pages, you'll have to declare a global variable and set the watermark keeping in mind that it'll be printed on the next page.
Upvotes: 2
Reputation: 292
If we want to display watermark in active report based on conditions its bit difficult with watermark property of the report. Instead we can use DrawText which appears similar to watermark on the report.
Code goes like this :
Sub GroupHeader1_BeforePrint
if(TxtFlg.text = "1") Then
Me.rpt.CurrentPage.ForeColor = Color.FromArgb(80, 128,128,128)
Me.rpt.CurrentPage.Font = New Font("Arial", 45F)
Me.rpt.CurrentPage.DrawText("DRAFT", 0.489F, 5F, 8, 2)
else
Me.rpt.CurrentPage.ForeColor = Color.FromArgb(80, 255, 255, 255)
Me.rpt.CurrentPage.Font = New Font("Arial", 20F)
Me.rpt.CurrentPage.DrawText("", 1.5F, 3F, 2, 2)
End If
End Sub
Upvotes: 1