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

时间:2021-05-20

本文实例展示了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); } } }}

代码运行效果如下:

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章