ToolTipControlInfo Class
Contains tooltip information.
Namespace: DevExpress.Utils
Assembly: DevExpress.Utils.v24.2.dll
Declaration
Related API Members
The following members return ToolTipControlInfo objects:
Remarks
ToolTipControlInfo objects are used to provide tooltip information via the ToolTipController.GetActiveObjectInfo event. To provide a tooltip for a control’s element when handling the ToolTipController.GetActiveObjectInfo event assign a ToolTipControlInfo object containing tooltip information to the event’s ToolTipControllerGetActiveObjectInfoEventArgs.Info parameter. See the ToolTipController.GetActiveObjectInfo topic for more information.
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:
- Create and initialize a new instance of the ToolTipController class.
- Assign the ToolTipController to the Grid Control’s GridControl.ToolTipController property.
- Handle the ToolTipController.GetActiveObjectInfo event.
The image below shows the result:
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)}
};
}
}
}