XtraReport.WatermarkId Property
Bindable. Specifies the unique identifier of a watermark to be displayed in a report.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.2.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
[DefaultValue(null)]
[SRCategory(ReportStringId.CatAppearance)]
public string WatermarkId { get; set; }
Property Value
Type | Default | Description |
---|---|---|
String | null | A watermark unique identifier. |
Remarks
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 Watermark CreateTextWatermark(string text, string id) {
Watermark textWatermark = new Watermark();
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;
}
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);
}
}
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.