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

Tooltip Displaying Wrong Data

1 Answer 9 Views
GridView
This is a migrated thread and some comments may be shown as answers.
WILLIAM
Top achievements
Rank 1
WILLIAM asked on 23 Jan 2014, 06:39 PM
Hi Telerik team,

I'm trying to implement the tooltip for each cell in a grid.  In some cases, the tooltip shows the correct value of the cell that is being hovered over; and sometimes it's incorrect.  See the attached screenshot for the case of it showing incorrectly.

Here is my code:
void GridViewCellLoaded_TT(object sender, CellEventArgs e)
{
    var cell = e.Cell as GridViewCell;
    if (cell == null || cell.Value == null || string.IsNullOrWhiteSpace(cell.Value.ToString())) return;
 
    var tt = cell.GetValue(ToolTipService.ToolTipProperty);
    if (tt != null) return;
     
    var tooltip = new ToolTip
    {
        Content = cell.Value
    };
    cell.SetValue(ToolTipService.ToolTipProperty, tooltip);           
}

Thanks!!

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 28 Jan 2014, 12:59 PM
Hello WILLIAM,

I am afraid that it is not recommended to work with the visual elements(in this case GridViewCell) directly. As you already know, RadGridView is virtualized control and as such, it only realizes the visual elements that are visible. When the virtualization of RadGridView is turned on (which is by default), it is not recommended to work with the visual elements and their properties. The rows and cells are reused and that is why we cannot rely on them. The better approach is to work with the data items. I can suggest you to check this help article which demonstrates how to set  a tooltip.


Regards,
Yoan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
WILLIAM
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or