How to customize the ToolTip for a TreeList cell
Yes, it’s possible. You should drop the ToolTipController onto a form, set the TreeList’s ToolTipController property and handle theToolTipController.GetActiveObjectInfo event.
[C#]
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.ViewInfo;
private void toolTipController1_GetActiveObjectInfo(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e) {
if(e.SelectedControl is DevExpress.XtraTreeList.TreeList) {
TreeList tree = (TreeList)e.SelectedControl;
TreeListHitInfo hit = tree.CalcHitInfo(e.ControlMousePosition);
if(hit.HitInfoType == HitInfoType.Cell) {
object cellInfo = new TreeListCellToolTipInfo(hit.Node, hit.Column, null);
string toolTip = string.Format("{0} (Column: {1}, Node ID: {2})", hit.Node[hit.Column], hit.Column.Caption, hit.Node.Id);
e.Info = new DevExpress.Utils.ToolTipControlInfo(cellInfo, toolTip);
}
}
}
[VB.NET]
Imports DevExpress.XtraTreeList
Imports DevExpress.XtraTreeList.ViewInfo
Private Sub toolTipController1_GetActiveObjectInfo(ByVal sender As Object, ByVal e As DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs) Handles toolTipController1.GetActiveObjectInfo
If TypeOf e.SelectedControl Is DevExpress.XtraTreeList.TreeList Then
Dim tree As TreeList = CType(e.SelectedControl, TreeList)
Dim hit As TreeListHitInfo = tree.CalcHitInfo(e.ControlMousePosition)
If hit.HitInfoType = HitInfoType.Cell Then
Dim cellInfo As Object = New TreeListCellToolTipInfo(hit.Node, hit.Column, Nothing)
Dim toolTip As String = String.Format("{0} (Column: {1}, Node ID: {2})", hit.Node(hit.Column), hit.Column.Caption, hit.Node.Id)
e.Info = New DevExpress.Utils.ToolTipControlInfo(cellInfo, toolTip)
End If
End If
End Sub