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

TestProject.zip
0.40MB

▶ MainForm.cs

using System.Drawing;
using System.Drawing.Drawing2D;

using DevExpress.Data;
using DevExpress.Utils;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;

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

        #region 생성자 - MainForm()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            this.gridView.InitializeView
            (
                true,                          // Multi Select
                GridMultiSelectMode.RowSelect, // 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.OptionsBehavior.AutoExpandAllGroups = true;

            this.gridView.OptionsView.ShowGroupPanel = true;

            this.gridView.OptionsView.ShowGroupedColumns = true;

            this.gridView.OptionsView.GroupFooterShowMode = GroupFooterShowMode.VisibleAlways;

            this.gridControl.DataSource = new nwindDataSetTableAdapters.OrdersTableAdapter().GetData();

            this.gridView.Columns["OrderDate"].GroupIndex = 0;

            #region 그리드 그룹 요약 항목을 추가한다.

            GridGroupSummaryItem gridGroupSummaryItem = new GridGroupSummaryItem();

            gridGroupSummaryItem.FieldName               = "OrderDate";
            gridGroupSummaryItem.SummaryType             = SummaryItemType.Count;
            gridGroupSummaryItem.ShowInGroupColumnFooter = gridView.Columns["OrderDate"];
            gridGroupSummaryItem.DisplayFormat           = "{0:n0}";

            this.gridView.GroupSummary.Add(gridGroupSummaryItem);

            #endregion

            this.gridView.BestFitColumns();

            this.gridView.CustomDrawRowFooter     += gridView_CustomDrawRowFooter;
            this.gridView.CustomDrawRowFooterCell += gridView_CustomDrawRowFooterCell;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 그리드 뷰 행 바닥글 커스텀 그리기 - gridView_CustomDrawRowFooter(sender, e)

        /// <summary>
        /// 그리드 뷰 행 바닥글 커스텀 그리기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void gridView_CustomDrawRowFooter(object sender, RowObjectCustomDrawEventArgs e)
        {
            e.Cache.FillRectangle
            (
                e.Cache.GetGradientBrush(e.Bounds, Color.Red, Color.Maroon, LinearGradientMode.Horizontal),
                e.Bounds
            );

            e.Handled = true;
        }

        #endregion
        #region 그리드 뷰 행 바닥글 셀 커스텀 그리기 - gridView_CustomDrawRowFooterCell(sender, e)

        /// <summary>
        /// 그리드 뷰 행 바닥글 셀 커스텀 그리기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void gridView_CustomDrawRowFooterCell(object sender, FooterCellCustomDrawEventArgs e)
        {
            e.Bounds.Inflate(-5, -5);

            e.Appearance.ForeColor              = Color.Teal;
            e.Appearance.FontSizeDelta          = 3;
            e.Appearance.TextOptions.HAlignment = HorzAlignment.Center;

            e.DefaultDraw();

            e.Cache.DrawRectangle(e.Cache.GetPen(Color.DarkOliveGreen, 1), e.Bounds);

            e.Handled = true;
        }

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