A newer version of this page is available. Switch to the current version.

ToolTipController.GetActiveObjectInfo Event

Allows you to provide custom tooltips for any element of a control that implements the DevExpress.Utils.IToolTipControlClient interface.

Namespace: DevExpress.Utils

Assembly: DevExpress.Utils.v19.1.dll

Declaration

[DXCategory("Events")]
public event ToolTipControllerGetActiveObjectInfoEventHandler GetActiveObjectInfo
<DXCategory("Events")>
Public Event GetActiveObjectInfo As ToolTipControllerGetActiveObjectInfoEventHandler

Event Data

The GetActiveObjectInfo event's data class is ToolTipControllerGetActiveObjectInfoEventArgs. The following properties provide information specific to this event:

Property Description
ControlMousePosition Gets the position of the mouse cursor relative to the control's upper left corner.
Info Gets or sets an object which uniquely identifies the visual element at the current position.
SelectedControl Gets or sets the control for which a tooltip controller's event is fired. Inherited from ToolTipControllerEventArgsBase.
SelectedObject Gets or sets the element of the control for which the tooltip should be displayed. Inherited from ToolTipControllerEventArgsBase.

Remarks

DevExpress controls that need to support tooltips for their elements implement the DevExpress.Utils.IToolTipControlClient interface. For instance, the Grid Control implements this interface to display hints for its elements (column and band headers and cells). For other elements, tooltips are not displayed by default.

To enable tooltips for any element of a control that implements the DevExpress.Utils.IToolTipControlClient interface, you need to handle the GetActiveObjectInfo event. This event is fired when you move the mouse cursor over the control. To provide a tooltip for the control's element, assign a ToolTipControlInfo object containing tooltip information to the event's ToolTipControllerGetActiveObjectInfoEventArgs.Info parameter. The event's ToolTipControllerGetActiveObjectInfoEventArgs.ControlMousePosition parameter specifies the position of the mouse cursor relative to the control's upper left corner.

A ToolTipControlInfo object that is assigned to the event's ToolTipControllerGetActiveObjectInfoEventArgs.Info parameter must provide tooltip information. The ToolTipControlInfo.Text must specify the tooltip text. The ToolTipControlInfo.Object property must uniquely identify the currently processed element. Other properties of the ToolTipControlInfo class can be used to specify the tooltip's title, icon type and delay.

The value of the ToolTipControlInfo.Object property is used as an identifier. To display different tooltips for a control's elements, different ToolTipControlInfo objects with different values of the ToolTipControlInfo.Object properties must be used.

You can also handle the ToolTipController.BeforeShow event to customize the tooltip just prior to it being displayed onscreen.

Examples

The following example demonstrates a way of implementing custom tooltips for row indicator cells in the XtraGrid control. By default, the grid control does not support tooltips for row indicator cells. To provide tooltips, drop the ToolTipController component onto the grid's form, assign it to the grid control's EditorContainer.ToolTipController property and handle the ToolTipController.GetActiveObjectInfo event.

In our example, the tooltips will display the "Row N" text where N is the ordinal number of a row.

ToolTipController_GetActiveObject

using DevExpress.Utils;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
//...
private void toolTipController1_GetActiveObjectInfo(object sender, 
ToolTipControllerGetActiveObjectInfoEventArgs e) {
    if(e.SelectedControl != gridControl1) return;

    ToolTipControlInfo info = null;
    //Get the view at the current mouse position
    GridView view = gridControl1.GetViewAt(e.ControlMousePosition) as GridView;
    if(view == null) return;
    //Get the view's element information that resides at the current position
    GridHitInfo hi = view.CalcHitInfo(e.ControlMousePosition);
    //Display a hint for row indicator cells
    if(hi.HitTest == GridHitTest.RowIndicator) {
        //An object that uniquely identifies a row indicator cell
        object o = hi.HitTest.ToString() + hi.RowHandle.ToString();
        string text = "Row "+ hi.RowHandle.ToString();
        info = new ToolTipControlInfo(o, text);         
    }
    //Supply tooltip information if applicable, otherwise preserve default tooltip (if any)
    if (info != null)
        e.Info = info;
}
See Also