Change watermark

Stimulsoft Reports.NET discussion
Andre2
Posts: 47
Joined: Thu Jan 24, 2008 12:30 am
Location: Australia

Change watermark

Post by Andre2 »

Hi All
I need to be able to change the watermark text based on the value of a subtotal or total field on a report.
Can anyone offer some code/suggestion has to how I might do this
thanks
Andre
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Change watermark

Post by Edward »

Please write the following code in the Page1.BeforePrintEvent event handler something like this:

Code: Select all

Page1.Watermark.Text = Totals.Sum(Categories,Categories.CategoryID).ToString();
Categories - it is the DataSource and Categories.CategoryID - it is a field for calculation of the Total.

Also the condition for calculating of the Total can be used:

Code: Select all

Page1.Watermark.Text = Totals.Sum(Categories,Categories.CategoryID<3?Categories.CategoryID:0).ToString();
Thank you.
Andre2
Posts: 47
Joined: Thu Jan 24, 2008 12:30 am
Location: Australia

Change watermark

Post by Andre2 »

Hi There
Thankyou for your reply.
unfortunatly it does not make sense to me.

Is the code supposed to be added to the "code" of the report and if so where?

or

Am I supposed to add this code to my application prior to printing

I am looking for a way to change the text of the water mark to read...

If cint(Totals.Sum(Categories,Categories.CategoryID))0
Watermark.Text = "Invoice"
end if

I want the report to be self contained
Thanks

Andre

Andre2
Posts: 47
Joined: Thu Jan 24, 2008 12:30 am
Location: Australia

Change watermark

Post by Andre2 »

Any answer on this topic from support:redeye:
Brendan
Posts: 309
Joined: Sun Jul 16, 2006 12:42 pm
Location: Ireland

Change watermark

Post by Brendan »

You add this code to your report.

In the designer select your page.
In the properties window you should see some icon buttons at the top of this window. One will look like a Yellow lightning bolt. This will switch to the Events view for the Page. In there you will see the different events available for the Page and add the code to the BeforePrintEvent.
Andre2
Posts: 47
Joined: Thu Jan 24, 2008 12:30 am
Location: Australia

Change watermark

Post by Andre2 »

Thanks for that....Just one problem No icon or any button/tab pane that makes reference to "events"

My Design windows has no such property or button
Im using the April 14 release 2008.1.218
Andre2
Posts: 47
Joined: Thu Jan 24, 2008 12:30 am
Location: Australia

Change watermark

Post by Andre2 »

opps belay that last post...foundit:brick:
Andre2
Posts: 47
Joined: Thu Jan 24, 2008 12:30 am
Location: Australia

Change watermark

Post by Andre2 »

OK I have managed to add some code to the before print event :dreamer: and it works as expected...
But only whilst im using the designer to design and test the report.

When I call the report from my application via

If File.Exists(pReportPath) = False Then
MessageBox.Show("Sorry! The report " & pReportPath & " could not be found at the specified location!" & vbCrLf & "Please check that the report and its components exist!", "Advice", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
End If

StiReport1.Load(pReportPath)

Dim sqlDB As Stimulsoft.Report.Dictionary.StiSqlDatabase = TryCast(StiReport1.Dictionary.Databases("VisualApprovals"), Stimulsoft.Report.Dictionary.StiSqlDatabase)
If sqlDB IsNot Nothing Then
sqlDB.ConnectionString = My.Settings.ApprovalsConnectionString.ToString
Else

If pWaterMark.Length > 1 Then
'Default water mark
For Each page As Stimulsoft.Report.Components.StiPage In StiReport1.Pages
page.Watermark.Text = pWaterMark

''The following lines adjust the font to make appear
''the full string so that it occupies the full space available.
''(Code taken from another thread)

'Dim text As New Stimulsoft.Report.Components.StiText
'text.ClientRectangle = page.ClientRectangle
'text.Text.Value = page.Watermark.Text
'text.Angle = page.Watermark.Angle
'text.Page = page
'text.Font = New System.Drawing.Font(page.Watermark.Font.FontFamily, 1020)
'page.Watermark.Font = text.GetActualFont(page.Watermark.Text)
Next
End If


Try
StiReport1.Compile()
Catch ex As Exception
MessageBox.Show(ex.Message, "Report Combile Error Advice", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End Try

Try
StiReport1.Render()
Catch ex As Exception
MessageBox.Show(ex.Message, " StiReport.Render error", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
End Try
Me.Show()


It simply shows the default watermark and not the one I have set in the before printevent of the report.
Can anyone point me in the correct direction
many Thanks
Andre

Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Change watermark

Post by Edward »

I have just only one idea. Please check that you are loading the correct mrt file with the desired BeforePrintEvent. All your code is correct. Also please show the BeforePrintEvent in your realization.

Thank you.
Andre2
Posts: 47
Joined: Thu Jan 24, 2008 12:30 am
Location: Australia

Change watermark

Post by Andre2 »

Thanks
Yep am sure Im calling the correct report
Andre
Post Reply