程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> DevExpress完成自界說TreeListNode的Tooltip的辦法

DevExpress完成自界說TreeListNode的Tooltip的辦法

編輯:C#入門知識

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);
   }
 }
  }
}

代碼運轉後果以下:

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved