DevExpress完成自界說TreeListNode的Tooltip的辦法。本站提示廣大學習愛好者:(DevExpress完成自界說TreeListNode的Tooltip的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是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); } } } }
代碼運轉後果以下: