This is a migrated thread and some comments may be shown as answers.

Wrap Text Items in DropDownList

5 Answers 870 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Michael Landy
Top achievements
Rank 1
Michael Landy asked on 15 Sep 2010, 03:20 AM
Is there a way to have items in the dropdown automatically word wrap? 

5 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 20 Sep 2010, 03:00 PM
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
0
Mary
Top achievements
Rank 1
answered on 15 May 2017, 10:47 AM

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>
0
Mary
Top achievements
Rank 1
answered on 15 May 2017, 10:50 AM

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

0
Dimitar
Telerik team
answered on 15 May 2017, 11:14 AM
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.
0
Mary
Top achievements
Rank 1
answered on 15 May 2017, 11:33 AM
Works perfectly. Thank you!
Tags
DropDownList
Asked by
Michael Landy
Top achievements
Rank 1
Answers by
Peter
Telerik team
Mary
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or