■ PivotGridControl 클래스에서 피벗 그리드를 인쇄하고 내보내는 방법을 보여준다.
▶ MainWindow.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
<Window x:Class="TestProject.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxpg="http://schemas.devexpress.com/winfx/2008/xaml/pivotgrid" Width="800" Height="600" Title="피벗 그리드 인쇄하고 내보내기" FontFamily="나눔고딕코딩" FontSize="16"> <Grid> <dxpg:PivotGridControl x:Name="pivotGridControl" PrintLayoutMode="MultiplePagesLayout"> <dxpg:PivotGridControl.Fields> <dxpg:PivotGridField FieldName="Country" Area="RowArea" Caption="Country" /> <dxpg:PivotGridField FieldName="Slaes Person" Area="RowArea" Caption="Sales Person" /> <dxpg:PivotGridField FieldName="CategoryName" Area="ColumnArea" Caption="Product Category" /> <dxpg:PivotGridField FieldName="OrderDate" Area="ColumnArea" Caption="Year" GroupInterval="DateYear"/> <dxpg:PivotGridField FieldName="ProductName" Caption="Product" /> <dxpg:PivotGridField FieldName="Extended Price" Area="DataArea" CellFormat="c0" /> </dxpg:PivotGridControl.Fields> </dxpg:PivotGridControl> <Button x:Name="printPreviewButton" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="10" Width="120" Height="25" Content="Print Preview" Click="printPreviewButton_Click" /> </Grid> </Window> |
▶ MainWindow.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
using System.Windows; using TestProject.NorthwindDataSetTableAdapters; namespace TestProject { /// <summary> /// 메인 윈도우 /// </summary> public partial class MainWindow : Window { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainWindow() /// <summary> /// 생성자 /// </summary> public MainWindow() { InitializeComponent(); SalesPersonTableAdapter salesPersonTableAdapter = new SalesPersonTableAdapter(); this.pivotGridControl.DataSource = salesPersonTableAdapter.GetData(); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region Print Preview 버튼 클릭시 처리하기 - printPreviewButton_Click(sender, e) /// <summary> /// Print Preview 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void printPreviewButton_Click(object sender, RoutedEventArgs e) { string documentName = "Preview Document"; string title = "Print Preview"; this.pivotGridControl.ShowPrintPreview(this, documentName, title); } #endregion } } |