Back to Devexpress

PreviewOptions.SyncWithReportPageSettings Property

xtrareports-devexpress-dot-xtrareports-dot-configuration-dot-previewoptions.md

latest8.3 KB
Original Source

PreviewOptions.SyncWithReportPageSettings Property

Specifies how to synchronize document preview options with report page settings.

Namespace : DevExpress.XtraReports.Configuration

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
public SynchronizationMode SyncWithReportPageSettings { get; set; }
vb
Public Property SyncWithReportPageSettings As SynchronizationMode

Property Value

TypeDefaultDescription
SynchronizationModeAuto

Always , to synchronize settings; Never , to never synchronize; Auto , to synchronize only if horizontal anchoring is enabled for one of the report’s or subreport’s controls.

|

Available values:

NameDescription
Never

Never synchronize.

| | Always |

Synchronize.

| | Auto |

Synchronize if horizontal anchoring is enabled for a report or one of its subreports.

|

Property Paths

You can access this nested property as listed below:

Object TypePath to SyncWithReportPageSettings
Settings

.PreviewOptions .SyncWithReportPageSettings

|

Remarks

When the SyncWithReportPageSettings property is set to Always , the document page settings that you change in WinForms Print Preview or WPF Print Preview are synchronized with the report page settings. For example, if you use horizontal anchoring for a control and change the document’s margins in Print Preview , the control’s size changes to fit the new margin size. Each change in Print Preview invokes the XtraReport.CreateDocument method. This method recreates the document to apply the new settings. If you then print or export the document, it will include all the changes made in Print Preview.

Note

The SyncWithReportPageSettings property does not affect vertical anchoring. When you change the report’s bottom margin in Print Preview , the controls’ sizes do not adjust to the new report size even if their AnchorVertical property is set to Bottom or Both.

When the SyncWithReportPageSettings property is set to Auto , the settings are synchronized only if horizontal anchoring is enabled for one of the report’s or subreport’s controls.

If you do not need to synchronize settings between reports and their Print Preview , set the SyncWithReportPageSettings property to Never.

Examples

Set the SyncWithReportPageSettings Property for the Application

The code example below demonstrates how to create a simple report and set the SyncWithReportPageSettings property for the application.

csharp
using DevExpress.XtraReports.Configuration;
using DevExpress.XtraReports.UI;
using System.Drawing;
// ...
// Create a label and set its "AnchorHorizontal" property to "Both".
XRLabel label = new XRLabel() {
    AnchorHorizontal = HorizontalAnchorStyles.Both,
    Text = "Some content goes here...",
    Font = new Font("Tahoma", 20f),
    Borders = DevExpress.XtraPrinting.BorderSide.All,
    LocationF = new DevExpress.Utils.PointFloat(150F, 20F),
    WidthF = 350F
};

// Create a report with the label.
XtraReport report = new XtraReport() {
    Name = "XtraReport",
    Bands = {
        new DetailBand() {
        HeightF = 15,
        Controls = {label}
        }
    }
};

// The value of the "SyncWithReportPageSettings" property is set to "Auto" (the default value).
// Uncomment the line below to set it to "Never".
// Settings.Default.PreviewOptions.SyncWithReportPageSettings = SynchronizationMode.Never;
vb
Imports DevExpress.XtraReports.Configuration
Imports DevExpress.XtraReports.UI
Imports System.Drawing
' ...
' Create a label and set its "AnchorHorizontal" property to "Both".
Dim label As New XRLabel() With {
.AnchorHorizontal = HorizontalAnchorStyles.Both, 
.Text = "Some content goes here...", 
.Font = New Font("Tahoma", 20F), 
.Borders = DevExpress.XtraPrinting.BorderSide.All, 
.LocationF = New DevExpress.Utils.PointFloat(150F, 20F), 
.WidthF = 350F}

' Create a report with the label.
Dim report = New XtraReport() With {
    .Name = "XtraReport"}
Dim band = New DetailBand() With {
            .HeightF = 15}
Dim control = New XRPdfSignature()
band.Controls.Add(label)
report.Bands.Add(band)

' The value of the "SyncWithReportPageSettings" property is set to "Auto" (the default value).
' Uncomment the line below to set it to "Never".
' Settings.Default.PreviewOptions.SyncWithReportPageSettings = SynchronizationMode.Never;

The image below shows the initial report layout in Print Preview.

The report’s detail band contains the XRLabel control whose AnchorHorizontal property is set to Both.

The following examples demonstrate how different values of the SyncWithReportPageSettings property affect the horizontal anchoring of the XRLabel control when the report’s right margin is changed in Print Preview.

Print Preview. The value of the SyncWithReportPageSettings property is Auto. Since the label’s AnchorHorizontal property is enabled, the settings are synchronized. When the right margin is moved to the left, the label’s size changes to preserve the distance between the control’s right edge and the report’s right border.

Print Preview. The value of the SyncWithReportPageSettings property is Never. When the right margin is moved to the left, the label’s size and position do not change.

Dynamically Resize XRPictureBox

This example dynamically resizes the XRPictureBox control so that it occupies the entire client area when the end user resizes margins or changes page settings:

View Example: How to Dynamically Size an Image to Fit the Entire Page Client Area

Limitations

The property has no effect if you use auto fit in Print Preview.

See Also

PreviewOptions Class

PreviewOptions Members

DevExpress.XtraReports.Configuration Namespace