VisualItemFormatting tooltips

2 posts, 0 answers
  1. Matthew
    Matthew avatar
    16 posts
    Member since:
    Oct 2010

    Posted 20 May 2012 Link to this post

    Hi There,

    I'm working on a grid which has a GridViewComboBoxColumn. the column is often not wide enough the fit the item text. So i wanted to add a tool tip for each item in the list.
    I found this article which seemed to be what i was after:

    but my code doesn't seem to work:

    protected void rgDraft_CellEditorInitialized(object sender, GridViewCellEventArgs e)
        if (e.Column.Name == "Country")
            RadDropDownListEditor editor = (RadDropDownListEditor)this.rgDraft.ActiveEditor;
            RadDropDownListEditorElement editorElement = (RadDropDownListEditorElement)editor.EditorElement;
            editorElement.VisualItemFormatting += new VisualListItemFormattingEventHandler(delegate(object formattingsender, VisualItemFormattingEventArgs args)
                    args.VisualItem.ToolTipText = args.VisualItem.Text;

    Any idea why this doesn't work? I can do other things, like set the bgcolor to red and that works as expected

    Many thanks,
  2. Stefan
    Stefan avatar
    2908 posts

    Posted 23 May 2012 Link to this post

    Hi Matthew,

    Thank you for writing.

    We are aware of this limitation and it is already logged in PITS. Here is a link where you can add your vote for it:

    Meanwhile, you can show the tooltips, by using the following code:
    void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
        if (e.Column.Name == "combo")
            RadDropDownListEditor editor = (RadDropDownListEditor)e.ActiveEditor;
            RadDropDownListEditorElement editorElement = (RadDropDownListEditorElement)editor.EditorElement;
            editorElement.Popup.ToolTipTextNeeded -= new Telerik.WinControls.ToolTipTextNeededEventHandler(Popup_ToolTipTextNeeded);
            editorElement.Popup.ToolTipTextNeeded += new Telerik.WinControls.ToolTipTextNeededEventHandler(Popup_ToolTipTextNeeded);
    ToolTip tip = new ToolTip();
    void Popup_ToolTipTextNeeded(object sender, Telerik.WinControls.ToolTipTextNeededEventArgs e)
        RadListVisualItem item = sender as RadListVisualItem;
        if (item != null)
            tip.Show(item.ToolTipText, this, this.PointToClient(Cursor.Position));
    private void AssignTooltips(RadListVisualItem item)
        if (item.AutoEllipsis = true && TextRenderer.MeasureText(item.Text, item.Font).Width > item.Size.Width)
            item.ToolTipText = item.Text;
            item.ToolTipText = "";

    I hope this helps. Let us know if you have any other questions.

    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top