Back to Devexpress

PrintHelper Class

wpf-devexpress-dot-xpf-dot-printing-8f934e2c.md

latest4.0 KB
Original Source

PrintHelper Class

Provides methods to display a Print Preview for links, grids and reports.

Namespace : DevExpress.Xpf.Printing

Assembly : DevExpress.Xpf.Printing.v25.2.dll

NuGet Package : DevExpress.Wpf.Printing

Declaration

csharp
[DXLicenseWpfReporting]
public static class PrintHelper
vb
<DXLicenseWpfReporting>
Public Module PrintHelper

Remarks

To create a custom Print Preview window, use the DocumentPreviewWindow class.

Example

This example demonstrates how to use SimpleLink to print data from a non-hierarchical datasource.

To do this, perform the following steps.

csharp
using System;
using System.Globalization;
using System.Windows;
using DevExpress.Xpf.Printing;
// ...
string[] data;

private void button1_Click(object sender, RoutedEventArgs e) {
    // Create an array of strings.
    data = CultureInfo.CurrentCulture.DateTimeFormat.DayNames;

    // Create a link and specify a template and detail count for it.
    SimpleLink link = new SimpleLink();
    link.DetailTemplate = (DataTemplate)Resources["dayNameTemplate"];
    link.DetailCount = data.Length;

    // Create a document.
    link.CreateDetail += new EventHandler<CreateAreaEventArgs>(link_CreateDetail);

    // Show a Print Preview window.
    PrintHelper.ShowPrintPreviewDialog(this, link);
}

void link_CreateDetail(object sender, CreateAreaEventArgs e) {
    e.Data = data[e.DetailIndex];
}
vb
Imports System
Imports System.Globalization
Imports System.Windows
Imports DevExpress.Xpf.Printing
' ...
Private data() As String

Private Sub button1_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    ' Create an array of strings.
    data = CultureInfo.CurrentCulture.DateTimeFormat.DayNames

    ' Create a link and specify a template and detail count for it.
    Dim link As New SimpleLink()
    link.DetailTemplate = DirectCast(Resources("dayNameTemplate"), DataTemplate)
    link.DetailCount = data.Length

    ' Create a document.
    AddHandler link.CreateDetail, AddressOf link_CreateDetail

    ' Show a Print Preview window.
    PrintHelper.ShowPrintPreviewDialog(Me, link)
End Sub

Private Sub link_CreateDetail(ByVal sender As Object, ByVal e As CreateAreaEventArgs)
    e.Data = data(e.DetailIndex)
End Sub

Inheritance

Object PrintHelper

See Also

PrintHelper Members

How to: Use the Simple Link

WPF Reporting Document Preview

DevExpress.Xpf.Printing Namespace