This is a migrated thread and some comments may be shown as answers.

RadGridView's Tooltip supports only text?

1 Answer 266 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Markus
Top achievements
Rank 1
Markus asked on 09 Jul 2008, 12:47 PM
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

1 Answer, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 11 Jul 2008, 02:45 PM
Hello Sebastian,

Currently, RadGridView does not support build-in customization of its RadToolTip. Nevertheless, you could use standard customizable ToolTip. Please, review the code-block below as an example:
 
private ToolTip cellToolTip; 
 
public Form1() 
    InitializeComponent(); 
 
 
private void Form1_Load(object sender, EventArgs e) 
    this.cellToolTip = new ToolTip(); 
 
    this.cellToolTip.BackColor = Color.Black; 
    this.cellToolTip.ForeColor = Color.White; 
    this.cellToolTip.InitialDelay = 300; 
    this.cellToolTip.ReshowDelay = 0;    
 
private void radGridView1_ToolTipTextNeeded(object sender, Telerik.WinControls.ToolTipTextNeededEventArgs e) 
    GridDataCellElement dataCell = sender as GridDataCellElement; 
 
    if (dataCell != null
    { 
        if (cellToolTip != null
        { 
            this.cellToolTip.Active = false
 
            this.cellToolTip.AutoPopDelay = dataCell.Value.ToString().Length * 200; 
            if (this.cellToolTip.AutoPopDelay < 5000) 
            { 
                this.cellToolTip.AutoPopDelay = 5000; 
            } 
 
            this.cellToolTip.SetToolTip(this.radGridView1, dataCell.Value.ToString()); 
 
            this.cellToolTip.Active = true
        } 
    } 
    else 
    { 
        this.cellToolTip.Active = false
    } 
 

I hope this helps. If you have other questions, do not hesitate to contact me again.

 
Kind regards,
Martin Vasilev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Markus
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Share this question
or