Tooltip Displaying Wrong Data

2 posts, 0 answers
  1. WILLIAM
    WILLIAM avatar
    134 posts
    Member since:
    Jun 2012

    Posted 23 Jan 2014 Link to this post

    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!!
  2. Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 28 Jan 2014 Link to this post

    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 >>
  3. DevCraft banner
Back to Top