첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

using DevExpress.Utils;
using DevExpress.Utils.Drawing;
using DevExpress.XtraGrid.Views.Grid;

...

private GridView gridView;

...

this.gridView.CustomDrawColumnHeader += gridView_CustomDrawColumnHeader;
this.gridView.FocusedColumnChanged   += gridView_FocusedColumnChanged;

...

private void gridView_CustomDrawColumnHeader(object sender, ColumnHeaderCustomDrawEventArgs e)
{
    if(e.Column == null)
    {
        return;
    }

    Brush brush        = new LinearGradientBrush(e.Bounds, Color.AliceBlue , Color.DodgerBlue, 90);
    Brush pressedBrush = new LinearGradientBrush(e.Bounds, Color.WhiteSmoke, Color.Gray      , 90);

    Rectangle rectangle = e.Bounds;

    ControlPaint.DrawBorder3D
    (
        e.Graphics,
        rectangle,
        (e.Info.State == ObjectState.Pressed ? Border3DStyle.SunkenOuter : Border3DStyle.RaisedInner)
    );

    rectangle.Inflate(-1, -1);

    e.Graphics.FillRectangle((e.Info.State == ObjectState.Pressed ? pressedBrush : brush), rectangle);
							
    if(e.Column.AbsoluteIndex == this.gridView.FocusedColumn.AbsoluteIndex)
    {
        e.Appearance.Font = new Font(AppearanceObject.DefaultFont, FontStyle.Bold);

        e.Appearance.ForeColor = Color.Navy;
    }
    else
    {
        e.Appearance.Font = AppearanceObject.DefaultFont;

        e.Appearance.ForeColor = SystemColors.WindowText;
    }
    
    e.Appearance.DrawString(e.Cache, e.Column.GetTextCaption(), e.Info.CaptionRect);

    e.Info.InnerElements.DrawObjects(e.Info, e.Info.Cache, Point.Empty);

    e.Handled = true;
}

private void gridView_FocusedColumnChanged(object sender, FocusedColumnChangedEventArgs e)
{
    this.gridView.InvalidateColumnHeader(null);
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요