xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xtrareport-932cb53e.md
Bindable. Specifies the unique identifier of a watermark to be displayed in a report.
Namespace : DevExpress.XtraReports.UI
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
[DefaultValue(null)]
[SRCategory(ReportStringId.CatAppearance)]
public string WatermarkId { get; set; }
<SRCategory(ReportStringId.CatAppearance)>
<DefaultValue(Nothing)>
Public Property WatermarkId As String
| Type | Default | Description |
|---|---|---|
| String | null |
A watermark unique identifier.
|
WatermarkId allows you to specify a watermark from the collection to display in the report. This property has a priority over the watermark’s PageRange property.
The following code snippet adds two watermarks in WatermarkCollection and displays the second watermark in a report:
using DevExpress.Drawing;
using DevExpress.XtraPrinting.Drawing;
using DevExpress.XtraReports.UI;
// ...
XtraReportCategories report = new XtraReportCategories();
report.Watermarks.Add(CreateTextWatermark("First Watermark","Watermark1"));
report.Watermarks.Add(CreateTextWatermark("Second Watermark", "Watermark2"));
report.WatermarkId = "Watermark2";
report.ShowRibbonPreviewDialog();
// ...
private XRWatermark CreateTextWatermark(string text, string id) {
XRWatermark textWatermark = new XRWatermark();
textWatermark.Text = text;
textWatermark.Id = id;
textWatermark.TextDirection = DirectionMode.ForwardDiagonal;
textWatermark.Font = new DXFont("Verdana", 36);
textWatermark.TextPosition = WatermarkPosition.InFront;
textWatermark.ForeColor = Color.Red;
return textWatermark;
}
Imports DevExpress.Drawing
Imports DevExpress.XtraPrinting.Drawing
Imports DevExpress.XtraReports.UI
' ...
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
Dim report As New XtraReportCategories()
report.Watermarks.Add(CreateTextWatermark("First Watermark","Watermark1"))
report.Watermarks.Add(CreateTextWatermark("Second Watermark", "Watermark2"))
report.WatermarkId = "Watermark2"
report.ShowRibbonPreviewDialog()
End Sub
' ...
Private Function CreateTextWatermark(ByVal text As String, ByVal id As String) As XRWatermark
Dim textWatermark As New XRWatermark()
textWatermark.Text = text
textWatermark.Id = id
textWatermark.TextDirection = DirectionMode.ForwardDiagonal
textWatermark.Font = New DXFont("Verdana", 36)
textWatermark.TextPosition = WatermarkPosition.InFront
textWatermark.ForeColor = Color.Red
Return textWatermark
End Function
End Class
Bind WatermarkId to an expression to apply watermarks stored in the collection to specific report pages.
The following code snippet adds different watermarks to the first, odd, and even pages of XtraReport:
using DevExpress.XtraReports.UI;
// ...
public partial class XtraReport : DevExpress.XtraReports.UI.XtraReport {
private void XtraReport_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e){
XtraReport report = new XtraReport();
ExpressionBinding watermarksBinding = new ExpressionBinding();
watermarksBinding.EventName = nameof(BeforePrint);
// Specify an expression that is rendered within the BeforePrint event.
watermarksBinding.Expression = "`Iif([Arguments.PageIndex]=0,'Watermark_0',Iif([Arguments.PageIndex]%2=0,'Watermark_1','Watermark_2'))`";
watermarksBinding.PropertyName = nameof(WatermarkId);
report.ExpressionBindings.Add(watermarksBinding);
}
}
Imports DevExpress.XtraReports.UI
' ...
Partial Public Class XtraReportCategories
Inherits DevExpress.XtraReports.UI.XtraReport
Private Sub XtraReport_BeforePrint(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
Dim report As New XtraReport()
Dim watermarksBinding As New ExpressionBinding()
watermarksBinding.EventName = NameOf(BeforePrint)
' Specify an expression that is rendered within the BeforePrint event.
watermarksBinding.Expression = "`Iif([Arguments.PageIndex]=0,'Watermark_0',Iif([Arguments.PageIndex]%2=0,'Watermark_1','Watermark_2'))`"
watermarksBinding.PropertyName = NameOf(WatermarkId)
report.ExpressionBindings.Add(watermarksBinding)
End Sub
End Class
The image below shows the result.
Review the following help topic for more information on how to bind expressions to report elements: Data Binding Modes.
See Also