修改SourceGrid字体显示 转

修改SourceGrid字体显示

新的SourceGrid DotNet版本是4.40,主要问题是在实现的时候显示的字体实在不敢恭维。

项目源:http://sourcegrid.codeplex.com/

介绍:http://www.codeproject.com/Articles/3531/SourceGrid-Open-Source-C-Grid-Control

修改两行代码搞定:

SourceGrid\DevAge.Windows.Forms\Drawing\VisualElements\TextGDI.cs

protected override void OnDraw(GraphicsCache graphics, RectangleF area)
        {
            if (Value == null || Value.Length == 0)
                return;

            SolidBrush brush;

            if (Enabled)
                brush = graphics.BrushsCache.GetBrush(ForeColor);
            else
                brush = graphics.BrushsCache.GetBrush(Color.FromKnownColor(KnownColor.GrayText));
            graphics.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            graphics.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            graphics.Graphics.DrawString(Value, Font, brush, area, StringFormat);
        }

强制使用高清的方式实现字体显示。

修改前:

image

修改后:

image

posted on 2013-05-30 21:31  武胜-阿伟  阅读(358)  评论(0编辑  收藏  举报