Add customise tootip to RadGridView cell on Mouse Hover or Enter.

6 posts, 0 answers
  1. Rajeev
    Rajeev avatar
    10 posts
    Member since:
    Apr 2008

    Posted 16 Apr 2008 Link to this post

    Hi,

    I need to implement a customise tootip on my RadGridView cell when user hover mouse on a particular column cell. A tooltip will be displayed showing data of that row. My ToolTip is a user control and when user hover on cell , respective tooltip is shown. I need to know which event of RadGridView will perform this and how to access cell on which user hover mouse. Please help, i need this urgently. Please let me know if some more information required. Thanks in advance,
  2. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 16 Apr 2008 Link to this post

    Hi Rajeev,

    Thank you for this question.

    RadGridView supports the standard windows tooltips for its cells. You can set a tooltip to a cell using this code:

    void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) 
        if (e.CellElement.Value != null
        { 
            e.CellElement.ToolTipText = e.CellElement.Value.ToString(); 
        } 

    If you want to use a custom tooltip, you should process the CellMouseMove event.

    Consider the following sample code:

    ToolTip tip = new ToolTip(); 
     
    void radGridView1_CellMouseMove(object sender, MouseEventArgs e) 
        GridCellElement cell = (GridCellElement)sender; 
        if (cell.Value != null
        { 
            tip.Show(cell.Value.ToString(), this.radGridView1, e.X, e.Y); 
        } 

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

    Greetings,
    Jack
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Carlos
    Carlos avatar
    1 posts
    Member since:
    Jan 2012

    Posted 10 Jan 2012 Link to this post

    when I tried this I got an error : cannot convert RadGridView in GridCellElement

    the type of sender is RadGridView what can I do???
    I do this because i need to show the text into a RadRichTextBox

    private void rgv_Precio_MouseMove(object sender, MouseEventArgs e)
            {
                GridCellElement cell = (GridCellElement)sender;
                if (cell.Value != null)
                {
                    rrtb_Ayuda.Text = ayuda[cell.ColumnIndex]; // (cell.Value.ToString(), this.rgv_Usuarios, e.X, e.Y);
                }
            }

    ayuda is a string[] where i have the list of text
  5. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 12 Jan 2012 Link to this post

    Hello Carlos,

    You are using quite an old version of RadControls for WinForms. In the newer versions we changed the event argument to be the cell where the event occurs. In your version you should use the GetElementAtPoint method to get the cell element. Here is a sample:
    void radGridView1_CellMouseMove(object sender, MouseEventArgs e)
    {
        GridCellElement cell = this.radGridView1.GetElementAtPoint(e.Location) as GridCellElement;
        if (cell != null && cell.Value != null)
        {
            rrtb_Ayuda.Text = ayuda[cell.ColumnIndex]; // (cell.Value.ToString(), this.rgv_Usuarios, e.X, e.Y);
        }
    }

    I recommend that you try our latest release which contains many improvements and new controls. We will appreciate also your feedback.

    If you have other questions, we will be glad to help.
     
    Kind regards,
    Jack
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

  6. Miguel Angel
    Miguel Angel avatar
    3 posts
    Member since:
    Oct 2012

    Posted 26 Oct 2012 Link to this post

    Which version do you mean?
  7. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 29 Oct 2012 Link to this post

    Hello Miguel,

    The version discussed in this particular ticket is Q3 2011, while our current version is Q3 2012. However, I just noticed that there is a mistake in my sample code. The GetElementAtPoint method is part of the ElementTree property of RadGridView. Here is the corrected code:
    void radGridView1_CellMouseMove(object sender, MouseEventArgs e)
    {
        GridCellElement cell = this.radGridView1.ElementTree.GetElementAtPoint(e.Location) as GridCellElement;
        if (cell != null && cell.Value != null)
        {
            rrtb_Ayuda.Text = ayuda[cell.ColumnIndex]; // (cell.Value.ToString(), this.rgv_Usuarios, e.X, e.Y);
        }
    }

    I hope this helps.

    Kind regards,
    Jack
    the Telerik team
    Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
Back to Top
UI for WinForms is Visual Studio 2017 Ready