Office File API & Office-Inspired Desktop UI Controls – Tips & Tricks (January-March 2021)

The first portion of this blog post includes interesting support tickets answered over the last few months. The second half includes enhancements to our Office & PDF File API/Office-inspired UI controls for WinForms and WPF.

We hope you find the contents of this post of value as you explore our Office-inspired product line. Should you have any questions, feel free to comment below.

Tips & Tricks

PDF Document API

  1. T964645 - How to use PDF Document API in an AWS Lambda function

WinForms and WPF Rich Text Editors

  1. T969099 - How to programmatically scroll a document to a bookmark

  2. T966380 - How to disable right-to-left selection

    To disable backward selection, change cursor position within the SelectionChanged event handler:

    private void RichEditControl1_SelectionChanged(object sender, EventArgs e)
        if (richEditControl1.Document.Selection.Length > 0 
            && richEditControl1.Document.CaretPosition.ToInt() < 
            richEditControl1.Document.CaretPosition = 
  3. T967667 - How to preserve custom colors selected in the Border and Shading dialog after the form has been closed

WinForms Spreadsheet Control

  1. T972881 - How to conditionally show/hide the Merge Cells ribbon button

  2. T970327 - How to change worksheet tab color

  3. T969696 - How to automatically resize a row that contains horizontally merged cells

    Activate the SpreadsheetCellOptions.AutoFitMergedCellRowHeight property to enable AutoFit for rows with horizontally merged cells:

    var cellOptions = spreadsheetControl1.Options.Cells;
    cellOptions.AutoFitMergedCellRowHeight = true;

WinForms PDF Viewer

  1. T970229 - How to preset a printer name in the Print dialog

    Specify the PrinterSettings.PrinterName property within the PageSetupDialogShowing event handler:

    private void PdfViewer1_PageSetupDialogShowing(object sender, 
        PdfPageSetupDialogShowingEventArgs e)
        e.PrinterSettings.Settings.PrinterName = "MyPrinter"; 

WinForms and WPF Spell Checker

  1. T974031 - How to change suggestion order in the spell checker's Suggestion List

  2. T970433 - How to enable spell checking for a ButtonEdit instance

    You can use the SpellingSettings.RegisterTextControl method to enable spell checking for a text editor that is inherited from TextBox, RichTextBox, or TextEdit.

    public MainWindow() {
               // ...

    In XAML, configure the text control's DXSpellChecker behavior:

    <!-- ... -->
        <dxe:ButtonEdit Height="300" Width="700" Text="Mispelled teext" >
                <dxspch:DXSpellChecker CheckAsYouType="True"
                                    	ShowSpellCheckMenu="True" >


Word Processing Document API and Rich Text Editors (for WinForms and WPF)

  1. T979035 – You can now access an OLE Package object’s properties

WinForms Rich Text Editor

  1. Improved Dialog Form Layout

    We redesigned our WinForms Rich Text Editor’s dialogs using our DevExpress Layout Control. This allowed us to address form scaling issues for High-DPI devices and applications with non-default localization and fonts.

Spreadsheet Document API and Spreadsheet Controls (for WinForms and WPF)

  1. T970413 – Use new PivotDataFieldCollection.Add and PivotDataFieldCollection.Insert method overloads to create data fields and specify the summary functions used to calculate field values

    // Create pivot table.
    // Use cell range "A1:E65" as a data source.
    var pivotTable = worksheet.PivotTables.Add(sourceWorksheet["A1:E65"], worksheet["B2"]);
    // Add "Category" and "Product" fields to row axis area.
    // Add "Amount" field to data area.
    // Use "Average" function to summarize field values.
    var dataField = pivotTable.DataFields.Add(pivotTable.Fields["Amount"], 
    	"Average of AMOUNT", PivotDataConsolidationFunction.Average);
  2. We improved copy and paste behavior for our WinForms and WPF Spreadsheets. With this update, if you copy data from a worksheet that contains filtered rows, the Spreadsheet control will not paste hidden cells onto a destination worksheet.

  3. We implemented the following Microsoft Excel compatible functions:

Excel Export Library

  1. T970359 - You can now use the IXlCell.HasQuotePrefix property to specify whether to treat a number, date, or formula used in a cell as text and prevent its use in calculations

    using (IXlCell cell = row.CreateCell())
        cell.Value = "=A2";
        cell.HasQuotePrefix = true;

WinForms PDF Viewer

  1. T974619 – Use the PdfViewer.AllowCommentReplies property to disable replies to comments in the Navigation pane

    pdfViewer1.AllowCommentReplies = false;
  2. T974621 – Set the PrintStickyNotes property to false to disable printing for sticky notes

    PdfPrinterSettings printerSettings = new PdfPrinterSettings();
    printerSettings.PrintStickyNotes = false;

PDF Document API

  1. T974576 – You can now use PdfViewerPreferences class properties to specify a document’s initial view settings

    using (var pdfDocumentProcessor = new PdfDocumentProcessor())
        var viewerPreferences = new PdfViewerPreferences();
        viewerPreferences.DisplayDocTitle = false;
        viewerPreferences.FitWindow = true;
        viewerPreferences.HideToolbar = true;
        pdfDocumentProcessor.Document.ViewerPreferences = viewerPreferences;
  2. T971338 – You can now retrieve the number of pages in a document to be signed

New Help Topics & Examples

Word Processing Document API

WinForms Rich Text Editor

WPF Rich Text Editor

New Example: PDF Document API

The following example demonstrates use of the Azure Key Vault API to digitally sign a PDF document.

As always, if you’ve come across an interesting support ticket you’d like to share with the rest of the DevExpress developer community, please comment below and include the appropriate link.

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.