Devexpress GridControl自定义Header背景颜色

本文介绍了如何在DevExpress GridControl中自定义列头(ColumnHeader)的背景颜色。通过处理GridView的CustomDrawColumnHeader事件,并设定特定条件,如当Column.FieldName等于'Category_Name'时,将背景颜色填充为珊瑚色。同时,文章提到了解决info.Visible编译问题的方案,即设置GridControl的LookAndFeel Style为UltraFlat,UseDefaultLookAndFeel设为False,并调整HeaderPanel的BackColor和ForeColor属性。
摘要由CSDN通过智能技术生成
  笔者在开发一个MES系统看板模块时采用的是Devexpress GridControl  (10.1版 ) 的控件,希望使用GridControl的Header的背景颜色和内容的一致在网上查找了一下使用如下一段代码

public static void CustomDrawColumnHeader(GridControl gridControl, GridView gridView) {
// Handle this event to paint columns headers manually
gridView.CustomDrawColumnHeader += (s, e) => {
if (e.Column == null || e.Column.FieldName != “Category_Name”)
return;
// Fill column headers with the specified colors.
e.Cache.FillRectangle(Color.Coral, e.Bounds);
e.Appearance.DrawString(e.Cache, e.Info.Caption, e.Info.CaptionRect);
// Draw the filter and sort buttons.
foreach (DrawElementInfo info in e.Info.InnerElements) {
if (!info.Visible) continue;
ObjectPainter.DrawObject(e.Cache, info.ElementPainter, info.ElementInfo);
}
e.Handled = true;
};
}
发现info.Visible编译通不过,后来发现最简单的方法是用如下截图设置:
<

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值