■ GridOptionsPrint 클래스 : UsePrintStyles 속성을 사용해 인쇄 모양(Appearance) 수정하기

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


TestProject.zip


MainForm.cs

 

 

using System;

using System.Drawing;

using System.Data.OleDb;

using System.Windows.Forms;

 

using DevExpress.Utils;

using DevExpress.XtraEditors;

using DevExpress.XtraGrid.Views.Grid;

 

namespace TestProject

{

    /// <summary>

    /// 메인 폼

    /// </summary>

    public partial class MainForm : XtraForm

    {

        //////////////////////////////////////////////////////////////////////////////////////////////////// Field

        ////////////////////////////////////////////////////////////////////////////////////////// Private

 

        #region Field

 

        /// <summary>

        /// 연결

        /// </summary>

        private OleDbConnection connection;

 

        #endregion

 

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

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

 

        #region 생성자 - MainForm()

 

        /// <summary>

        /// 생성자

        /// </summary>

        public MainForm()

        {

            InitializeComponent();

 

            this.connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=nwind.mdb");

 

            this.gridView.InitializeView

            (

                true,                           // Multi Select

                GridMultiSelectMode.CellSelect, // Grid Multi Select Mode

                DrawFocusRectStyle.CellFocus,   // Draw Focus Rect Style

                true,                           // Show Indicator

                true,                           // Show Column Headers

                true,                           // Allow Column Moving

                true,                           // Allow Column Resizing

                true,                           // Allow Filter

                true,                           // Allow Sort

                false,                          // Allow Cell Merge

                EditorShowMode.Default,         // Editor Show Mode

                false                           // Editable

            );

 

            this.gridView.OptionsBehavior.AutoPopulateColumns = true;

 

            this.gridView.OptionsPrint.UsePrintStyles = true;

 

            this.gridView.OptionsPrint.EnableAppearanceEvenRow = true;

 

            this.gridView.AppearancePrint.EvenRow.BackColor = Color.LightYellow;

 

            this.gridControl.DataSource = Customer.GetCustomerList(this.connection);

 

            this.gridView.BestFitColumns();

 

            this.executeButton.Click += executeButton_Click;

        }

 

        #endregion

 

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

        ////////////////////////////////////////////////////////////////////////////////////////// Private

 

        #region 실행 버튼 클릭시 처리하기 - executeButton_Click(sender, e)

 

        /// <summary>

        /// 실행 버튼 클릭시 처리하기

        /// </summary>

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

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

        private void executeButton_Click(object sender, EventArgs e)

        {

            if(!this.gridControl.IsPrintingAvailable)

            {

                XtraMessageBox.Show

                (

                    this,

                    "ERROR",

                    "DevExpress.XtraPrinting 라이브러리를 찾을 수 없습니다.",

                    MessageBoxButtons.OK,

                    MessageBoxIcon.Error

                );

 

                return;

            }

 

            this.gridControl.ShowPrintPreview();

        }

 

        #endregion

    }

}

 

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

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요