KB Article A474
Visible to All Users

How to customize the ToolTip for a TreeList cell

Description:
Is it possible to display a custom tooltip for a node cell?

Answer:
Yes, it's possible. You should drop the ToolTipController onto a form, set the TreeList's ToolTipController property and handle the ToolTipController.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); } } }
Visual Basic
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

See Also:
Showing a hint for a grid cell even if its content is completely visible
How to get multi-line tooltips with a specific width
How to programmatically display a tooltip for a control via the ToolTipController component
How to display a hint for an active editor within the XtraGrid
How to display hints only for particular cells
ToolTipController class

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.