Page 1 of 2
Change watermark
Posted: Tue Apr 29, 2008 1:07 am
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
Change watermark
Posted: Tue Apr 29, 2008 1:26 pm
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.
Change watermark
Posted: Tue Apr 29, 2008 8:29 pm
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
Change watermark
Posted: Wed Apr 30, 2008 4:27 pm
by Andre2
Any answer on this topic from support:redeye:
Change watermark
Posted: Wed Apr 30, 2008 4:33 pm
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.
Change watermark
Posted: Wed Apr 30, 2008 11:08 pm
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
Change watermark
Posted: Wed Apr 30, 2008 11:09 pm
by Andre2
opps belay that last post...foundit:brick:
Change watermark
Posted: Thu May 01, 2008 1:17 am
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
Change watermark
Posted: Thu May 01, 2008 1:31 am
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.
Change watermark
Posted: Thu May 01, 2008 7:11 am
by Andre2
Thanks
Yep am sure Im calling the correct report
Andre