Description:
I want to show a tooltip for a text editor inside the XtraGrid. I tried to use the ToolTipController, but without success. Is there a way I can do this?
Answer:
Actually, it's possible to achieve this with the help of the ToolTipController using the following approach. First, within the GridView's ShownEditor event you should assign a new handler of the GetActiveObjectInfo event to the ToolTipController of the currently active editor. This is necessary because the Grid doesn't display hints for editors by default (please see the ToolTipController.GetActiveObjectInfo Event topic of the XtraGrid help file for details). Then within the GetActiveObjectInfo event you should create a new ToolTipControlInfo for the displayed editor and specify the hint text you wish to display. Then everything should work fine. Here is some sample code:
C#private void gridView1_ShownEditor(object sender, System.EventArgs e) {
DevExpress.XtraGrid.Views.Grid.GridView gridView = sender as DevExpress.XtraGrid.Views.Grid.GridView;
if (gridView.ActiveEditor.ToolTipController != null) {
gridView.ActiveEditor.ToolTipController.GetActiveObjectInfo +=new DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventHandler(ToolTipController_GetActiveObjectInfo);
}
}
private void ToolTipController_GetActiveObjectInfo(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e) {
ToolTipControlInfo info = null;
object o = gridView1.ActiveEditor.ToString();
string text = "Test";
info = new ToolTipControlInfo(o, text);
e.Info = info;
}
Attached you will find a sample project demonstrating this approach.
See Also:
How to customize the ToolTip for a TreeList cell
Showing a hint for a grid cell even if its content is completely visible
How to get multi-line tooltips with a specific width
How to programmatically display a tooltip for a control via the ToolTipController component
How to display hints only for particular cells
Not working. gridView.ActiveEditor gives null. Also i spent half day searching for a very basic thing like this.
There is not a single consistent example/tutorial. Lots of links, read this documentation. Help ZERO.
Hello,
To process your recent post in the most efficient manner, I have created a separate ticket on your behalf: T151460: Code from the "How to display a hint for an active editor within XtraGrid" example does not work. Let's continue our discussion there.
I have the same Problem… is there still an answer?
Hello,
In order not to mix several questions within one thread, I will extract your question to a new ticket. Let us continue our discussion there GridView.ActiveEditor gives null.