Skip to main content

ToolTipControllerGetActiveObjectInfoEventArgs.Info Property

Gets or sets an object which uniquely identifies the visual element at the current position.

Namespace: DevExpress.Utils

Assembly: DevExpress.Utils.v23.2.dll

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

Declaration

public ToolTipControlInfo Info { get; set; }

Property Value

Type Description
ToolTipControlInfo

A ToolTipControlInfo object which identifies the visual element at the current position.

Remarks

The ToolTipController.GetActiveObjectInfo event is called repeatedly when the mouse cursor moves over a control. To display a hint for the control’s specific element, check the current mouse position and if the mouse hovers over the required element assign a ToolTipControlInfo object containing tooltip information to the event’s Info parameter. The ToolTipControlInfo.Text property must specify the hint to display. The ToolTipControlInfo.Object property must be set to a value that uniquely identifies the current element.

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. If you assign the same ToolTipControlInfo object to the Info parameter as in the previous event call the tooltip will not be redisplayed even if a new tooltip text is specified.

If you assign a new ToolTipControlInfo object but the object assigned to the ToolTipControlInfo.Object property is the same as in the previous event call, the tooltip will not be redisplayed either. If you assign a new ToolTipControlInfo object to the parameter and change the ToolTipControlInfo.Object property as compared to the previous event call, the previous hint will be hidden and the new hint will be displayed.

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 Info property.

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