Tooltips
Flexible TreeView allows you to show tooltips for nodes, node controls, and columns' header. Tooltip settings may be changed in the Tooltips treeview property.
Below are the main tooltip parameters:
- Enabled - defines whether to show tooltips.
- Position - defines how to position a tooltip along with the object for which it is shown.
Available values:- Standard - show tooltip near the mouse cursor.
- UnderObject - show tooltip under the object.
- SourceOrder - defines an order of retrieving a tooltip text when many objects are under the mouse cursor at the same time. Treeview contains a group of object containers inside (for instance, a node contains a group of node controls) and this option defines the order of those containers when retrieving tooltip text.
Available values:- Node - get tooltip text from a node under the mouse cursor while ignoring all node controls that are also under the cursor. The node class's member name where the tooltip text is stored should be in the NodeFieldName property.
- NodeControlThenNode - first, get a tooltip for a node control under the mouse cursor, and then, if not found, for a node.
- NodeFieldName - contains the node class's member name, where the tooltip for the node is stored. Used when the SourceOrder has the Node value.
Tooltip text retrieval logic#
When the tooltip is about to show, the treeview will take the following steps to retrieve the tooltip text from different sources:
- If the mouse is over a treeview column, the column GetTooltipText is called and its return value is used.
- If the mouse is over a node control and treeview.Tooltips.SourceOrder is NodeControlThenNode, the node control GetTooltipText is called and its return value is used. By default, GetTooltipText returns the node property value that is bound to this node control.
- If the treeview.Tooltips.NodeFieldName is specified, the node (under the mouse cursor) property which name is specified in the NodeFieldName is used.
- If none of above requirements are met the tooltip is not shown.
Customize the tooltip for specific node or node control#
When the default tooltip behavior is not what fits your project requirements, Flexible TreeView allows you to customize the tooltip visibility for each column, node or node control by using the TooltipPopup treeview event.
In order to change the tooltip text for any column, node or node control, or hide the tooltip at all for them but show it for others, the TooltipPopup event need to be handled. To hide the tooltip for some object, the args.Text property should be cleared, as shown in below example.
tree.Tooltips.Enabled = true;
tree.TooltipPopup += OnTooltipPopup;
void OnTooltipPopup(FlexibleTreeView treeview, TooltipEventArgs args)
{
BindableControl ctrl = args.NodeControl as BindableControl;
if(ctrl != null)
{
// Show tooltip for a node control that is bound to the 'Number' node property.
if(ctrl.DataFieldName == "Number")
return;
// Show tooltip for a node control that has 'invalid' in its bound property text value.
string textValue = ctrl.GetValueAsString(args.Node);
if(!textValue.Contains("invalid"))
return;
}
// Do not shown the tooltip for others.
args.Text = null;
}
tree.Tooltips.Enabled = True
tree.TooltipPopup += OnTooltipPopup
Private Sub OnTooltipPopup(treeview As FlexibleTreeView, args As TooltipEventArgs)
Dim ctrl As BindableControl = TryCast(args.NodeControl, BindableControl)
If ctrl IsNot Nothing Then
' Show tooltip for a node control that is bound to the 'Number' node property.
If ctrl.DataFieldName = "Number" Then
Return
End If
' Show tooltip for a node control that has 'invalid' in its bound property text value.
Dim textValue As String = ctrl.GetValueAsString(args.Node)
If Not textValue.Contains("invalid") Then
Return
End If
End If
' Do not shown the tooltip for others.
args.Text = Nothing
End Sub
Custom tooltip provider#
Flexible TreeView allows you to use a third-party tooltips engine to seamlessly integrate the treeview into your application. To do that, you need to implement the ITooltipProvider interface and apply your tooltip provider to the TooltipProvider treeview property.