첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
다운로드

▶ CustomLocalizer.cs

using System;

using DevExpress.XtraPivotGrid.Localization;

namespace TestProject
{
    /// <summary>
    /// 커스텀 로컬라이저
    /// </summary>
    public class CustomLocalizer : PivotGridResLocalizer
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 지역화 문자열 구하기 - GetLocalizedString(id)

        /// <summary>
        /// 지역화 문자열 구하기
        /// </summary>
        /// <param name="id">ID</param>
        /// <returns>지역화 문자열</returns>
        public override string GetLocalizedString(PivotGridStringId id)
        {
            if
            (
                id == PivotGridStringId.DataHeadersCustomization   ||
                id == PivotGridStringId.ColumnHeadersCustomization ||
                id == PivotGridStringId.FilterHeadersCustomization
            )
            {
                return String.Empty;
            }

            return base.GetLocalizedString(id);
        }

        #endregion
    }
}

 

728x90

 

▶ MainForm.cs

using System;
using System.Data;
using System.Drawing;

using DevExpress.XtraEditors;
using DevExpress.XtraPivotGrid;
using DevExpress.XtraPivotGrid.Localization;

namespace TestProject
{
    /// <summary>
    /// 메인 폼
    /// </summary>
    public partial class MainForm : XtraForm
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainForm()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainForm()
        {
            PivotGridLocalizer.Active = new CustomLocalizer();

            InitializeComponent();

            Load += Form_Load;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

        #region 폼 로드시 처리하기 - Form_Load(sender, e)

        /// <summary>
        /// 폼 로드시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void Form_Load(object sender, EventArgs e)
        {
            this.pivotGridControl.BeginUpdate();

            this.pivotGridControl.DataSource = GetTable(20);

            this.pivotGridControl.Fields.Add("Type"   , PivotArea.RowArea);
            this.pivotGridControl.Fields.Add("Product", PivotArea.RowArea);

            PivotGridField yearField = new PivotGridField("Date", PivotArea.RowArea);

            yearField.Name          = "yearField";
            yearField.Caption       = yearField.Name;
            yearField.GroupInterval = PivotGroupInterval.DateYear;

            PivotGridField monthField = new PivotGridField("Date", PivotArea.RowArea);

            monthField.Name          = "monthField";
            monthField.Caption       = monthField.Name;
            monthField.GroupInterval = PivotGroupInterval.DateMonth;

            pivotGridControl.Fields.AddRange(new PivotGridField[] { yearField, monthField });

            pivotGridControl.Fields.Add("Flag", PivotArea.RowArea);

            this.pivotGridControl.CustomDrawFieldValue += pivotGridControl_CustomDrawFieldValue;

            this.pivotGridControl.Appearance.Lines.BackColor = Color.Transparent;

            this.pivotGridControl.EndUpdate();
        }

        #endregion
        #region 피벗 그리드 컨트롤 필드 값 커스텀 그리기 - pivotGridControl_CustomDrawFieldValue(sender, e)

        /// <summary>
        /// 피벗 그리드 컨트롤 필드 값 커스텀 그리기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void pivotGridControl_CustomDrawFieldValue(object sender, PivotCustomDrawFieldValueEventArgs e)
        {
            if(e.Area == PivotArea.ColumnArea)
            {
                e.Graphics.FillRectangle(Brushes.White, e.Bounds);

                e.Handled = true;
            }
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////// Function

        #region 테이블 구하기 - GetTable(rowCount)

        /// <summary>
        /// 테이블 구하기
        /// </summary>
        /// <param name="rowCount">행 수</param>
        /// <returns>테이블</returns>
        private DataTable GetTable(int rowCount)
        {
            DataTable table = new DataTable();

            table.Columns.Add("Type"   , typeof(string  ));
            table.Columns.Add("Product", typeof(string  ));
            table.Columns.Add("Date"   , typeof(DateTime));
            table.Columns.Add("Flag"   , typeof(bool    ));

            for(int i = 0; i < rowCount; i++)
            {
                for(int j = 0; j < rowCount; j++)
                {
                    table.Rows.Add
                    (
                        new object[]
                        {
                            string.Format("Type {0}", i % 5),
                            string.Format("Product {0}", i % 3),
                            DateTime.Now.AddYears(j % 7).AddMonths(j % 9), i % 2 == 0
                        }
                    );
                }
            }

            return table;
        }

        #endregion
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요