当前位置: 移动技术网 > IT编程>开发语言>c# > DevExpress设置TreeList图片节点背景色的方法

DevExpress设置TreeList图片节点背景色的方法

2019年07月18日  | 移动技术网IT编程  | 我要评论

本文实例展示了devexpress设置treelist图片节点背景色的方法,在项目开发中有一定的应用价值,具体方法如下所示:

主要功能代码如下:

/// <summary>
/// 设置图片节点的背景色
/// 说明:在customdrawnodeimages事件中使用
/// </summary>
/// <param name="tree">treelist</param>
/// <param name="e">customdrawnodeimageseventargs</param>
/// <param name="builderbackcolorhandler">委托</param>
public static void customimagenodebackcolor(this treelist tree, customdrawnodeimageseventargs e, func<treelistnode, color> builderbackcolorhandler)
{
  treelistnode _node = e.node;
  color _backcolor = builderbackcolorhandler(_node);
  e.graphics.fillrectangle(new solidbrush(_backcolor), e.bounds);
}

代码使用方法如下:

private void tllhdata_customdrawnodeimages(object sender, customdrawnodeimageseventargs e)
{
  try
  {
 tllhdata.customimagenodebackcolor(e, node =>
 {
   string _cabid = node.getkeyid();
   ccabinfo _cabinfo = lhdbhelper.getcabinfo(_cabid);
   if (_cabinfo != null)
   {
 return _cabinfo.ctuonlinestatus == 1 ? color.white : color.lightgray;
   }
   return color.white;
 });
  }
  catch (exception)
  {

  }
}

代码运行效果如下图所示:

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网