Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Utilize a Print Preview Dialog to Adjust Margins in the RichEditControl Document

This example illustrates how to handle the PrintingSystemBase.AfterMarginsChange event to apply margin settings adjusted in the Print Preview dialog to the document loaded in the RichEditControl. The document is printed via the PrintableComponentLink and the PrintTool.ShowPreviewDialog method is used to display the Print Preview window.

void PrintingSystem_AfterMarginsChange(object sender, MarginsChangeEventArgs e) {
    // Change document margins in the source RichEditControl
    SectionMargins margins = this.richEditControl1.Document.Sections[0].Margins;
    switch (e.Side) {
        case MarginSide.Left:
            margins.Left = Units.HundredthsOfInchToDocuments((int)e.Value);
            break;
        case MarginSide.Right:
            margins.Right = Units.HundredthsOfInchToDocuments((int)e.Value);
            break;
        case MarginSide.Top:
            margins.Top = Units.HundredthsOfInchToDocuments((int)e.Value);
            break;
        case MarginSide.Bottom:
            margins.Bottom = Units.HundredthsOfInchToDocuments((int)e.Value);
            break;
        default:
            break;
    }

    link.CreateDocument();
}