Skip to main content

Obtain a Label's Text in Print Preview

  • 2 minutes to read

To obtain a label’s text when clicking it in Print Preview, do the following:

  1. Create a new application or open an existing application. For more information, review the following help topic: Get Started with DevExpress Reporting.

  2. Add a new blank report to the application.
  3. Drop two XRLabel controls from the DX.22.2: Report Controls Toolbox tab onto the Detail band.


  4. To get a label’s content in Print Preview, do one of the following (depending on the target platform):

    • Print Preview for Windows Forms

      Handle the XRControl.PreviewClick and/or XRControl.PreviewDoubleClick events of the added controls in the following way:

      using System;
      using System.Windows.Forms;
      using DevExpress.XtraReports.UI;
      // ...
      private void xrLabel1_PreviewClick(object sender, PreviewMouseEventArgs e) {
      private void xrLabel2_PreviewDoubleClick(object sender, PreviewMouseEventArgs e) {

      Run the application and click a label to view the result.


    • Document Preview for WPF

      Use the DocumentPreviewControl.DocumentPreviewMouseClick and/or DocumentPreviewControl.DocumentPreviewMouseDoubleClick events as shown in the code snippet below.

      using DevExpress.XtraPrinting;
      using DevExpress.Xpf.Printing;
      private void documentPreview_DocumentPreviewMouseClick_1(DependencyObject d, DocumentPreviewMouseEventArgs e) {
          LabelBrick brick = e.Brick as LabelBrick;
          if (brick != null)
    • Web Document Viewer

      Handle the client-side ASPxClientWebDocumentViewer.PreviewClick event as demonstrated below.

      <script type="text/javascript" id="script">
          function previewClick(s, e) {
              e.Brick && alert(e.Brick.text())
      <dx:ASPxWebDocumentViewer ID="ASPxWebDocumentViewer1" runat="server" ReportSourceId="WebWebDocumentViewer.XtraReport1">
          <ClientSideEvents PreviewClick="previewClick"/>
See Also