SimpleLink.CreateDetail Event

Occurs every time the detail area of a SimpleLink is created.

Namespace: DevExpress.Xpf.Printing

Assembly: DevExpress.Xpf.Printing.v20.1.dll

Declaration

public event EventHandler<CreateAreaEventArgs> CreateDetail
Public Event CreateDetail As EventHandler(Of CreateAreaEventArgs)

Event Data

The CreateDetail event's data class is CreateAreaEventArgs. The following properties provide information specific to this event:

Property Description
Data Gets or sets the object, which represents data for the area creation event.
DetailIndex Gets or sets the index of a detail row for which the area creation event was called.

Remarks

The CreateDetail event is raised after the LinkBase.CreateDocument method is called for the SimpleLink object. This event is raised as many times as specified by the SimpleLink.DetailCount property value.

Handle the CreateDetail event to provide data for the detail area. An object containing data should be assigned to the CreateAreaEventArgs.Data property, and it will be represented using the template provided by the SimpleLink.DetailTemplate property.

NOTE

Do not pass visual objects (such as TextBox, Canvas, etc.) as detail area data, or the printing engine will not work as expected.

Examples

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

To do this, perform the following steps.

NOTE

A complete sample project is available at https://github.com/DevExpress-Examples/how-to-use-the-simple-link-e1673.

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];
}
See Also