Skip to main content

ToolTipController.GetActiveObjectInfo Event

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

Namespace: DevExpress.Utils

Assembly: DevExpress.Utils.v23.2.dll

NuGet Packages: DevExpress.Utils, DevExpress.Wpf.Core

Declaration

[DXCategory("Events")]
public event ToolTipControllerGetActiveObjectInfoEventHandler GetActiveObjectInfo

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 assign the ToolTipController component to the control’s ToolTipController property and handle the ToolTipController.GetActiveObjectInfo event.

The GetActiveObjectInfo event is fired when you move the mouse pointer over the control. To provide a tooltip for the control’s element, assign a ToolTipControlInfo object containing tooltip information to the event’s e.Info parameter. The event’s e.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 e.Info parameter must provide tooltip information. The ToolTipControlInfo.Text specifies the text for a regular or super tooltip. The ToolTipControlInfo.FlyoutControl property specifies a flyout tooltip’s content. 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.

Example

The following example demonstrates how to display custom tooltips for row indicator cells in the WinForms Data Grid control. The Grid control does not display tooltips for row indicator cells by default.

Do the following:

  1. Create and initialize a new instance of the ToolTipController class.
  2. Assign the ToolTipController to the Grid Control’s GridControl.ToolTipController property.
  3. Handle the ToolTipController.GetActiveObjectInfo event.

The image below shows the result:

Display Custom ToolTips for Row Indicator Cells in the WinForms Data Grid Control

using System;
using System.Collections.Generic;
using DevExpress.Utils;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid;

namespace DXApplication18 {
    public partial class Form1 : XtraForm {
        ToolTipController tooltipController;
        public Form1() {
            InitializeComponent();
            // Initializes a ToolTip Controller.
            tooltipController = new ToolTipController();
            // Assigns the ToolTip Controller to the GridControl.
            gridControl1.ToolTipController = tooltipController;

            /* Handles the GetAvticeObjectInfo event to display custom tooltips
             * for the grid's row indicator cells.
             */
            tooltipController.GetActiveObjectInfo += tooltipController_GetActiveObjectInfo;

            // Binds the GridControl to data generated at runtime.
            gridControl1.DataSource = Task.GetSampleData();
        }
        void tooltipController_GetActiveObjectInfo(object sender,
ToolTipControllerGetActiveObjectInfoEventArgs e) {
            if (e.SelectedControl != gridControl1) return;

            ToolTipControlInfo info = null;
            // Gets the Data View at the mouse pointer position.
            GridView view = gridControl1.GetViewAt(e.ControlMousePosition) as GridView;
            if (view == null) return;
            // Gets the information about UI element that resides at the mouse pointer position.
            GridHitInfo hi = view.CalcHitInfo(e.ControlMousePosition);
            // Displays a tooltip if the mouse pointer is over a row indicator cell.
            if (hi.HitTest == GridHitTest.RowIndicator) {
                // Gets an object that uniquely identifies the row indicator cell.
                object o = hi.HitTest.ToString() + hi.RowHandle.ToString();
                string text = String.Empty;
                switch (hi.RowHandle) {
                    case GridControl.AutoFilterRowHandle:
                        text = "Auto Filter Row";
                        break;
                    case GridControl.NewItemRowHandle:
                        text = "New Item Row";
                        break;
                    case GridControl.InvalidRowHandle:
                        text = "Invalid Row Handle";
                        break;
                    default:
                        text = String.Format("Row {0}", hi.RowHandle);
                        break;
                }
                info = new ToolTipControlInfo(o, text);
            }

            if(info != null)
                e.Info = info;
        }
    }
    public class Task {
        int fID;
        public Task(int id) {
            fID = id;
            CreateDate = DateTime.Today;
        }
        public int ID {
            get {
                return fID;
            }
        }
        public string Caption { get; set; }
        public DateTime CreateDate { get; set; }
        public static List<Task> GetSampleData() {
            return new List<Task>() {
            new Task(0){Caption = "Research", CreateDate = new DateTime(2022, 10, 15)},
            new Task(1){Caption = "UI Design", CreateDate = new DateTime(2022, 11, 5)},
            new Task(2){Caption = "Environment Setup", CreateDate = new DateTime(2022, 11, 10)},
            new Task(3){Caption = "Sprint 1", CreateDate = new DateTime(2022, 11, 11)},
            new Task(4){Caption = "Sprint 2", CreateDate = new DateTime(2022, 12, 12)},
            new Task(5){Caption = "Sprint 3", CreateDate = new DateTime(2023, 1, 10)},
            new Task(6){Caption = "Testing", CreateDate = new DateTime(2022, 2, 10)}
        };
        }
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the GetActiveObjectInfo event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also