Tooltip on a cell in edit mode

2 posts, 0 answers
  1. Dreyfus
    Dreyfus avatar
    17 posts
    Member since:
    May 2019

    Posted 22 Jun Link to this post

    Is there a way to show a tooltip on a cell in edit mode?
  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3891 posts

    Posted 23 Jun Link to this post

    Hello, Jay,  

    RadGridView offers a convenient way for showing tool tips for the cell elements when they are not being edited: https://docs.telerik.com/devtools/winforms/controls/gridview/cells/tooltips 

    Once an editor is activated, it handles the keyboard and mouse input. That is why the cell's tooltip is not shown. 

    The following code snippet demonstrates a sample approach how to show a tool tip when a RadTextBoxEditor is initialized. The attached gif file illustrates the achieved result. Note that this is just a sample approach and it may not cover all possible cases. Feel free to modify and extend it for the other editor types in order to achieved the desired custom behavior.
            RadToolTip toolTip;
    
            public RadForm1()
            {
                InitializeComponent();
                 
                this.radGridView1.CellEditorInitialized += radGridView1_CellEditorInitialized;
                this.radGridView1.CellEndEdit += radGridView1_CellEndEdit;
            }
    
            private void radGridView1_CellEndEdit(object sender, GridViewCellEventArgs e)
            {
                toolTip.Hide();
            }
    
            private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
            {
                RadTextBoxEditor tbEditor = e.ActiveEditor as RadTextBoxEditor;
                if (tbEditor != null)
                {
                    if (toolTip == null)
                    {
                        toolTip = new RadToolTip();
                        toolTip.InitialDelay = 0;
                    }
    
                    RadTextBoxEditorElement elementUnderMouse = tbEditor.EditorElement as RadTextBoxEditorElement;
                    if (elementUnderMouse != null)
                    {
                        toolTip.Show(elementUnderMouse.Text, Cursor.Position);
                    }
                }
            }

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top