您现在的位置是: 首页  >  IT编程

DevExpress实现自定义TreeListNode的Tooltip的方法

程序员文章站 2023-12-18 11:32:16
本文实例展示了devexpress实现自定义treelistnode的tooltip的方法,具体方法如下所示: 主要功能代码如下: ///

本文实例展示了devexpress实现自定义treelistnode的tooltip的方法,具体方法如下所示:

主要功能代码如下:

/// <summary>
/// 为节点提供tooltip
/// 说明:
/// 1.设置tree.tooltipcontroller属性
/// 2.tooltipcontroller的getactiveobjectinfo事件中使用
/// 3.举例
/// tllhdata.customnodetooltip(e, node =>
///{
///  string _cabid = node.getkeyid();
///  ccabinfo _cabinfo = lhdbhelper.getcabinfo(_cabid);
///  if (_cabinfo != null)
///  {
///    return string.format("核对时间:{0}\r\n在线情况:{1}\r\n最后一次活跃时间:{2}\r\n",
///               _cabinfo.chkdatatime,
///               _cabinfo.ctuonlinestatus == 1 ? "在线" : "未上线",
///               _cabinfo.lastalivetime);
///  }
///  return string.empty;
///});
/// </summary>
/// <param name="tree">treelist</param>
/// <param name="e">tooltipcontrollergetactiveobjectinfoeventargs</param>
/// <param name="buildernodetooltiphandler">委托</param>
public static void customnodetooltip(this treelist tree, tooltipcontrollergetactiveobjectinfoeventargs e, func<treelistnode, string> buildernodetooltiphandler)
{
  if (e.selectedcontrol is devexpress.xtratreelist.treelist)
  {
 treelist _tree = (treelist)e.selectedcontrol;
 treelisthitinfo _hit = _tree.calchitinfo(e.controlmouseposition);
 if (_hit.hitinfotype == hitinfotype.cell)
 {
   treelistviewinfo _viewinfo = _tree.viewinfo;
   rowinfo _rowinfo = _viewinfo.getrowinfobypoint(e.controlmouseposition);
   cellinfo _cellinfo = _rowinfo.cells[_hit.column.visibleindex] as cellinfo;
   edithitinfo _edithitinfo = _cellinfo.editorviewinfo.calchitinfo(e.controlmouseposition);
   if (_edithitinfo.hittest == edithittest.maskbox)
   {
 string _tooltip = buildernodetooltiphandler(_hit.node);
 if (!string.isnullorempty(_tooltip))
   e.info = new tooltipcontrolinfo(_cellinfo, _tooltip);
   }
 }
  }
}

代码运行效果如下:

DevExpress实现自定义TreeListNode的Tooltip的方法

上一篇:

下一篇: