■ GridControl 클래스 : 그리드 인쇄하기/내보내기

----------------------------------------------------------------------------------------------------


TestProject.zip


MainWindow.xaml

 

 

<Window x:Class="TestProject.MainWindow"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"

    Width="800"

    Height="600"

    Title="그리드 인쇄하기/내보내기"

    FontFamily="나눔고딕코딩"

    FontSize="16">

    <Grid>

        <Grid.RowDefinitions>

            <RowDefinition Height="*"    />

            <RowDefinition Height="Auto" />

        </Grid.RowDefinitions>

        <dxg:GridControl x:Name="gridControl"

            AutoGenerateColumns="AddNew">

            <dxg:GridControl.View>

                <dxg:TableView x:Name="tableView" />

            </dxg:GridControl.View>

        </dxg:GridControl>

        <StackPanel

            Grid.Row="1"

            Margin="10"

            Orientation="Horizontal">

            <Button x:Name="showPrintPreview"

                Padding="5"

                Content="Show Print Preview"

                Click="showPrintPreview_Click" />

            <Button x:Name="exportToMSExcel"

                Margin="5 0 0 0"

                Padding="5"

                Content="Export To MS Excel"

                Click="exportToMSExcel_Click" />

        </StackPanel>

    </Grid>

</Window>

 

 

MainWindow.xaml.cs

 

 

using System.Windows;

 

namespace TestProject

{

    /// <summary>

    /// 메인 윈도우

    /// </summary>

    public partial class MainWindow : Window

    {

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor

        ////////////////////////////////////////////////////////////////////////////////////////// Public

 

        #region 생성자 - MainWindow()

 

        /// <summary>

        /// 생성자

        /// </summary>

        public MainWindow()

        {

            InitializeComponent();

 

            this.gridControl.ItemsSource = new IssueList().GetData();

        }

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method

        ////////////////////////////////////////////////////////////////////////////////////////// Public

 

        #region Show Print Preview 버튼 클릭시 처리하기 - showPrintPreview_Click(sender, e)

 

        /// <summary>

        /// Show Print Preview 버튼 클릭시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void showPrintPreview_Click(object sender, RoutedEventArgs e)

        {

            this.tableView.ShowPrintPreviewDialog(this);

        }

 

        #endregion

        #region Export To MS Excel 버튼 클릭시 처리하기 - exportToMSExcel_Click(sender, e)

 

        /// <summary>

        /// Export To MS Excel 버튼 클릭시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void exportToMSExcel_Click(object sender, RoutedEventArgs e)

        {

            this.tableView.ExportToXlsx(@"d:\grid_export.xlsx");

        }

 

        #endregion

    }

}

 

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요