Devexpress Printablecomponentlink

Printablecomponentlink

Imports DevExpress.Spreadsheet: Imports DevExpress.XtraPrinting # End Region ' #printingUsings: Namespace SpreadsheetControlAPI: Public NotInheritable Class PrintingActions: Private Sub New End Sub: Public Shared PrintAction As Action(Of IWorkbook) = AddressOf Print: Private Shared Sub Print(ByVal workbook As IWorkbook) Dim worksheet As. 3、在PrintableComponentLink添加文档页眉和页脚处理事件,进行相应的自定义的动态调整。 4、最后执行创建文档和打印操作。 DevExpress打印功能 z的更多相关文章. DevExpress打印功能介绍 z. Developer documentation for all DevExpress products. Name Parameters Description; ShowPreviewDialog none: Invokes the Print Preview Form which modally shows the print preview of the document for this link. Imports DevExpress.XtraPrinting: Imports DevExpress.XtraGrid.Views.Grid '. Namespace PrintDevExControls: Partial Public Class Form1: Inherits Form: Public Sub New InitializeComponent End Sub ' Create printing components. Private printingSystem1 As New PrintingSystem Private printableComponentLink1 As New PrintableComponentLink '. C# (CSharp) PrintableComponentLink.ShowPreview - 6 examples found. These are the top rated real world C# (CSharp) examples of PrintableComponentLink.ShowPreview extracted from open source projects. You can rate examples to help us improve the quality of examples.

1. 가로 스크롤 보이기

gridView1.OptionsView.ColumnAutoWidth = false;

gridView1 .HorzScrollVisibiity = Auto or Always

2. 프린터에서 필요없는 Footer 없애기

gridView1.OptionsPrint.PrintFooter = false;

3. 컬럼헤더 중앙정렬

gridview1 -> Column Properties -> Apperance Header -> TextOptions -> HAlignment = Center

4. 간단한 프린트 클래스 설정

using System;
using System.Collections.Generic;
using System.Text;
using DevExpress.XtraPrinting;
using System.Drawing;

namespace Test

{
class clsReport
{
string strTitle;
string _subContent=';
float _subHeight = 20;

System.Drawing.Printing.PaperKind PaperKind;

public string subContent { get { return _subContent; } set { _subContent = value; } }

#region Print with Title
// using DevExpress.XtraPrinting;

public void Print(DevExpress.XtraPrinting.IPrintable pGrid, string pTitle, System.Drawing.Printing.PaperKind pPaperKind, bool pLandscape)
{
Print(pGrid, pTitle, pPaperKind, pLandscape, 20);
}

public void Print(DevExpress.XtraPrinting.IPrintable pGrid, string pTitle, System.Drawing.Printing.PaperKind pPaperKind, bool pLandscape, float subHeight)
{
strTitle = pTitle;
PaperKind = pPaperKind;
_subHeight = subHeight;
PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem());
link.PaperKind = PaperKind;
link.Landscape = pLandscape;
link.Margins.Top = 100;
link.Margins.Bottom = 60;
link.Margins.Left = 50;
link.Margins.Right = 50;
link.Component = pGrid;
link.CreateMarginalHeaderArea += new CreateAreaEventHandler(Link_CreateMarginalHeaderArea);
link.CreateMarginalFooterArea += new CreateAreaEventHandler(Link_CreateMarginalFooterArea);
link.CreateDocument();
link.ShowPreview();
//link.ShowRibbonPreview(DevExpress.LookAndFeel.UserLookAndFeel.Default);
}


private void Link_CreateMarginalHeaderArea(object sender, CreateAreaEventArgs e)
{
PageInfoBrick brick = e.Graph.DrawPageInfo(PageInfo.None, strTitle, Color.DarkBlue, new RectangleF(0, 0, 110, 50), BorderSide.None);
brick.LineAlignment = BrickAlignment.Center;
brick.Font = new Font('굴림체', 18);
brick.Alignment = BrickAlignment.Center;
brick.AutoWidth = true;

PageInfoBrick Lbrick = e.Graph.DrawPageInfo(PageInfo.DateTime, ', Color.DarkBlue, new RectangleF(0, 0, 100, 20), BorderSide.None);
Lbrick.LineAlignment = BrickAlignment.Far;
Lbrick.Font = new Font('굴림체', 9);
Lbrick.Alignment = BrickAlignment.Far;
Lbrick.AutoWidth = true;

if (_subContent != ')
{
PageInfoBrick Sbrick = e.Graph.DrawPageInfo(PageInfo.DateTime, _subContent, Color.DarkBlue, new RectangleF(0, 0, 100, _subHeight), BorderSide.None);
Sbrick.LineAlignment = BrickAlignment.Far;
Sbrick.Font = new Font('굴림체', 9);
Sbrick.Alignment = BrickAlignment.Near;
Sbrick.AutoWidth = true;
}


}

private void Link_CreateMarginalFooterArea(object sender, CreateAreaEventArgs e)
{
PageInfoBrick brick = e.Graph.DrawPageInfo(PageInfo.None, CUser.Company, Color.DarkBlue, new RectangleF(0, 0, 100, 20), BorderSide.None);
brick.LineAlignment = BrickAlignment.Near;
brick.Font = new Font('굴림체', 9);
brick.Alignment = BrickAlignment.Center;
brick.AutoWidth = true;

PageInfoBrick Lbrick = e.Graph.DrawPageInfo(PageInfo.NumberOfTotal, ', Color.DarkBlue, new RectangleF(0, 0, 100, 20), BorderSide.None);
Lbrick.LineAlignment = BrickAlignment.Near;
Lbrick.Font = new Font('굴림체', 9);
Lbrick.Alignment = BrickAlignment.Far;
Lbrick.AutoWidth = true;
}
#endregion

Printablecomponentlink

}
}

※ 클래스 호출

clsReport cReport = new clsReport();
cReport.subContent = '조회조건 : ' + dtpFrom.Value.ToString('yyyy-MM-dd') ;
cReport.Print(gridControl2, '보고서', System.Drawing.Printing.PaperKind.A4, true);

Devexpress Printablecomponentlink
  • 3 minutes to read

This tutorial illustrates how to use the PrintableComponentLink to print DevExpress Windows Forms controls at runtime. For a design-time approach, refer to the How to: Preview, Export and Print a Windows Forms Control topic.

To get started with this tutorial, create a Windows Forms Application with a print preview, similar to the one created in the following tutorial: How to: Add a Print Preview to a Windows Forms Application.

This tutorial consists of the following sections.

Add a Grid Control

  1. Add a new page ('Grid') to the Ribbon toolbar using the Ribbon Control Designer. To learn how to manage ribbon items, see the Ribbon Items Page topic.
  2. To add a grid to the main form, press CTRL+ALT+X to open the Toolbox. Next, drag the GridControl control from the DX.20.2: Data & Analytics category and drop it on the form.

  3. Bind the grid control to data. To learn how to bind the grid control to data sources of different types, see the Examples: Data Binding topic.
  4. To use the Ribbon control's pages to quickly switch between the grid and print preview, handle the RibbonControl.SelectedPageChanged event, and add the following code to the event handler.

If you use printing system links to print or export data from a view, you should set the view's OptionsPrint.ShowPrintExportProgress property to false. Additionally, if the server mode is used, it is necessary to call the BaseView.ClearDocument method before printing or exporting data.

Create a Printing Link

The following code demonstrates how to create a PrintableComponentLink, add it to the PrintingSystem.Links collection, adjust its printing settings, and use it to print an existing GridControl.

Publish the Document

A Windows Forms application with a print preview is now ready. You can change the GridControl layout by applying grouping, filtering or sorting.

To preview the document, click the Print Preview tab on the Ribbon. Use the menu options in this tab to print and/or export the document to one of the available formats.