Wrap Text Items in DropDownList

6 posts, 0 answers
  1. Michael Landy
    Michael Landy avatar
    15 posts
    Member since:
    Dec 2009

    Posted 14 Sep 2010 Link to this post

    Is there a way to have items in the dropdown automatically word wrap? 
  2. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 20 Sep 2010 Link to this post

    Hello Michael Landy,

    Thanks for writing.
     
    You should set the AutoSizeItems property to True:

    radDropDownList1.AutoSizeItems = True;
     
    This property gets or sets a value that indicates whether items will be sized according to their content.

    Hope this helps.

    Greetings,
    Peter
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Mary
    Mary avatar
    3 posts
    Member since:
    May 2017

    Posted 15 May Link to this post

    Hi,

     

    How do I wrap text in the dropdown in a gridviewcomboboxcolumn? I'd like to keep the dropdown the same width as the column, but have any long entries wrapped. I've tried this, but is hasn't worked:

     

    <p>Private Sub grdComments_CellEditorInitialized(sender As Object, e As GridViewCellEventArgs) Handles grdComments.CellEditorInitialized<br></p><p>            Dim Editor = TryCast(e.ActiveEditor, RadDropDownListEditor)<br><br>            Editor.EditorElement.AutoSize = True<br><br>        End If<br><br>    End Sub</p>
  4. Mary
    Mary avatar
    3 posts
    Member since:
    May 2017

    Posted 15 May in reply to Mary Link to this post

    Wow. It would be good if I could edit posts, huh. Here's the code again:

     

    Private Sub grdComments_CellEditorInitialized(sender As Object, e As GridViewCellEventArgs) Handles grdComments.CellEditorInitialized

         Dim Editor = TryCast(e.ActiveEditor, RadDropDownListEditor)

         If Not IsNothing(Editor) Then

                Editor.EditorElement.AutoSize = True

         End if
           
        End Sub

  5. Dimitar
    Admin
    Dimitar avatar
    1699 posts

    Posted 15 May Link to this post

    Hello Mary,

    You need to set the AutoSizeItems and TextWrap properties:
    Private Sub RadGridView1_CellEditorInitialized(ByVal sender As Object, ByVal e As GridViewCellEventArgs)
        Dim editor = TryCast(e.ActiveEditor, RadDropDownListEditor)
        If editor IsNot Nothing Then
            Dim element = TryCast(editor.EditorElement, RadDropDownListEditorElement)
            element.AutoSizeItems = True
            RemoveHandler element.VisualItemFormatting, AddressOf Element_VisualItemFormatting
            AddHandler element.VisualItemFormatting, AddressOf Element_VisualItemFormatting
        End If
    End Sub
     
    Private Sub Element_VisualItemFormatting(ByVal sender As Object, ByVal args As VisualItemFormattingEventArgs)
        args.VisualItem.TextWrap = True
    End Sub

    Please let me know if there is something else I can help you with. 
     
    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. Mary
    Mary avatar
    3 posts
    Member since:
    May 2017

    Posted 15 May in reply to Dimitar Link to this post

    Works perfectly. Thank you!
Back to Top