winform开发,用devexpress中的gridcontrol控件,头部默认是3D样式,当客户希望像内容一样扁平化显示且需要添加垂直线(右边框)时
恶梦开始了。。
经过一阵摸索发现可以这样解决:

1.设置GridControl的GridView控件的PaintStyleName属性为Web

2.为GridControl的GridView控件添加CustomDrawColumnHeader事件,参考代码如下:

private void gridView1_CustomDrawColumnHeader(object sender, ColumnHeaderCustomDrawEventArgs e)
{
    if (e.Column == null) return;
    e.Painter.DrawObject(e.Info);
    using (Pen p1 = new Pen(Color.FromArgb(227, 227, 227), 2))
    {
        e.Graphics.DrawLine(p1, e.Bounds.X + e.Bounds.Width, e.Bounds.Y - 2, e.Bounds.X + e.Bounds.Width, e.Bounds.Y + e.Bounds.Height + 2);
    }
}

注:Color.FromArgb(227, 227, 227) 这是垂直线的颜色值
这时候如果有设置GridView中Appearance属性下的HeaderPanel下的BorderColor则会出现一些设定颜色值的间隙。
所以用此方法是最好在事件里设定颜色,另外还有一点点突出来的地方,这个应该不影响了。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2021-12-01
  • 2022-01-11
猜你喜欢
  • 2022-12-23
  • 2021-07-31
  • 2022-02-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案