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

using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;

...

private GridView gridView;

...

private ImageList imageList;

...

this.gridView.CustomDrawGroupRow += gridView_CustomDrawGroupRow;

...

private void gridView_CustomDrawGroupRow(object sender, RowObjectCustomDrawEventArgs e)
{
    GridGroupRowInfo groupInfo       = e.Info as GridGroupRowInfo;
    Rectangle        buttonRectangle = groupInfo.ButtonBounds;
    Rectangle        textRectangle   = groupInfo.Bounds;

    Brush brush	    = new LinearGradientBrush(textRectangle, Color.AliceBlue, Color.DodgerBlue, 0.0);
    Brush textBrush = Brushes.Black;

    if(e.RowHandle == this.gridView.FocusedRowHandle)
    {
        brush     = SystemBrushes.Highlight;
        textBrush = SystemBrushes.HighlightText;
    }

    e.Graphics.FillRectangle(brush, textRectangle);

    if(!buttonRectangle.IsEmpty)
    {
        textRectangle.Width = textRectangle.Right - (buttonRectangle.Right + 4);
        textRectangle.X     = buttonRectangle.Right + 4;

        int x = buttonRectangle.X;
        int y = textRectangle.Y + (textRectangle.Height - this.imageList.ImageSize.Height) / 2;

        e.Graphics.DrawImageUnscaled(this.imageList.Images[(this.gridView.GetRowExpanded(e.RowHandle) ? 1 : 0)], x, y);
    }

    string text = this.gridView.GetGroupRowDisplayText(e.RowHandle);

    e.Graphics.DrawString(text, e.Appearance.Font, textBrush, textRectangle, e.Appearance.GetStringFormat());

    e.Handled = true;
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요