Hi All,
I use the RadGridView to show text that is sometimes longer than the original cell. Since the complete text does not fit into the cell I decided to show a tool tip by using the ToolTipTextNeeded event. The problem is that this event only allows me to set a text for the tool tip. The tool tip itself disappears after only 5 seconds which makes it quite unusable for my implementation.
To find out why I cannot set an AutoPopDelay for the displayed tooltip I used a bit of Reflector magic and found out that the RadToolTip class being used is internal as well as the property that holds the tool tip for the cells. This is a bit stupid because now I can't even derive my own class.
In the end I decided to force the required values into the grid by using reflection but of course this is not the best way to solve this problem.
Shouldn't the ToolTipTextNeededEventArgs expose far more properties of the original tooltip or the entire tool tip itself?
Just in case someone else is having the some problem, I'll post my ToolTipTextNeeded event handler here:
private void gviAufgaben_ToolTipTextNeeded(object sender, ToolTipTextNeededEventArgs e) | |
{ | |
GridDataCellElement cell = sender as GridDataCellElement; | |
if (cell != null) | |
{ | |
ComponentBehavior behavior = cell.ElementTree.ComponentTreeHandler.Behavior; | |
PropertyInfo tooltip = behavior.GetType().GetProperty("ToolTip", BindingFlags.NonPublic | BindingFlags.Instance); | |
object tip = tooltip.GetValue(behavior, null); | |
PropertyInfo autoPopDelay = tip.GetType().GetProperty("AutoPopDelay"); | |
autoPopDelay.SetValue(tip, 60000, null); | |
e.ToolTipText = cell.Value.ToString(); | |
} | |
} |
I hope that someone can come up with a better suggestion.
Thanks,
Sebastian