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

DropDown Item Height Problem

8 Answers 322 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
DJ
Top achievements
Rank 1
DJ asked on 28 Mar 2011, 02:07 PM
Morning,

I'm testing out these controls and have run into a problem...  I hope someone can help.

I have a problem with automatically setting the item heights of the dropdown items.   In the attached image, you will see that the textbox font size is much larger than the items that appear in the drop down.   Since my application is a touch screen application, I need these to be larger so the users can actually interact with the items in the drop down and also the dropdown style must be combobox like so the user's can search the drop downs.

I have tried the following in several different groupings:
RadDropDownList1.ListElement.AutoSizeItems = True
RadDropDownList1.ListElement.ItemHeight = 34
RadDropDownList1.DropDownListElement.ItemHeight = 34
RadDropDownList1.DropDownListElement.AutoSize = True
RadDropDownList1.DropDownListElement.AutoSizeItems = True

If there are additional details/settings that would help, please let me know and I will include them.
Cheers
DJ

8 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 28 Mar 2011, 03:08 PM
Hello,

You can control the font of each item. Therefore, please consider the following code

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.RadDropDownList1.Items.Add("Item 1")
    Me.RadDropDownList1.Items.Add("Item 2")
    Me.RadDropDownList1.Items.Add("Item 3")
    Me.RadDropDownList1.Items.Add("Item 4")
    Dim font As New Font("Arial", 14)
    Me.RadDropDownList1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList
    Me.RadDropDownList1.Text = ""
    Me.RadDropDownList1.SelectedIndex = 0
    Me.RadDropDownList1.ListElement.AutoSizeItems = True
    Me.RadDropDownList1.DropDownListElement.Font = font
    For Each item As RadListDataItem In RadDropDownList1.ListElement.Items
        item.Font = font
    Next
End Sub

Hope that helps
Richard
0
DJ
Top achievements
Rank 1
answered on 29 Mar 2011, 01:03 PM
So all is mostly good.  Now i need to implement the same thing while the dropdown is in a gridview but I cannot see to find where to implement the code.  Any ideas?  & thanks for your previous reply.
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 29 Mar 2011, 04:10 PM
Hi,

You can do this via the CellEditorInitialized event.

E.g.
Private font As New Font("Arial", 14)

Private Sub RadGridView1_CellEditorInitialized(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles RadGridView1.CellEditorInitialized
    If TypeOf e.ActiveEditor Is RadDropDownListEditor Then
        Dim editor As RadDropDownListEditor = CType(e.ActiveEditor, RadDropDownListEditor)
        Dim element As RadDropDownListEditorElement = CType(editor.EditorElement, RadDropDownListEditorElement)
        element.ListElement.Font = font
        element.AutoSizeItems = True
    End If
End Sub

Hope this helps
Richard
0
Nino
Top achievements
Rank 1
answered on 18 Jul 2013, 03:55 PM
Your example works perfectly if i add items manually, but if i have a List<CustomObject> as a datasource of the dropdownlist it does not shows any of the items...

any idea pls?

here is my code;
ddlRtt <-RadDropDownList;
List<myCustomObject> ret;

                ddlRtt.DataSource = ret;
                ddlRtt.DisplayMember = "Desc";
                ddlRtt.ValueMember = "Id";
                Font f = new System.Drawing.Font("Segoe UI", 20, FontStyle.Bold);
                ddlRtt.ListElement.AutoSize = false;
                ddlRtt.DropDownListElement.Font = f;
                foreach (Telerik.WinControls.UI.RadListDataItem itm in ddlRtt.ListElement.Items)
                {
                    itm.Font = f;
                }

0
Keith
Top achievements
Rank 1
answered on 30 Apr 2015, 01:00 PM

I have the same issue where the RadDropDownList box is 200,51 size and is populated by a DataSource.  The font for the box is set to Calibri 27pt.  But when clicking on the box, the items shown are so small.  How do I set up the RadDropDownList box so the items have the same font and size as the text in the box?

Please help!

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 01 May 2015, 09:29 AM
Hello Keith,

Thank you for writing.

Your question has already been answered in the support ticket you have opened on the same topic. However, I am posting the answer here as well in order the community to benefit from it.

In order to apply the same font to the editable part of the RadDropDownList, its popup and the auto-complete popup, you need to set the Font property explicitly to each corresponding element:
Dim font As New Font("Calibri", 27, FontStyle.Regular)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.CustomersTableAdapter.Fill(Me.NwindDataSet.Customers)
    Me.RadDropDownList1.DataSource = Me.CustomersBindingSource
    Me.RadDropDownList1.DisplayMember = "ContactName"
    Me.RadDropDownList1.ValueMember = "CustomerID"
    Me.RadDropDownList1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown
    Me.RadDropDownList1.AutoCompleteMode = AutoCompleteMode.Suggest
  
    Me.RadDropDownList1.Font = font
    Me.RadDropDownList1.DropDownListElement.Popup.Font = font
    Me.RadDropDownList1.AutoSizeItems = True
    Me.RadDropDownList1.DropDownListElement.AutoCompleteSuggest.DropDownList.Popup.Font = font
End Sub

I hope this information helps. Should you have further questions, I would be glad to help.

Greetings,
Dess
the Telerik team
 
 
0
Keith
Top achievements
Rank 1
answered on 01 May 2015, 12:51 PM

Thanks to Telerik's support team!  They helped me find a solution.

Here is what I did:

                    Dim font As New Font("Calibri", 27)

                    Me.RadDropDownList1.DropDownListElement.Popup.Font = font
                    Me.RadDropDownList1.ListElement.AutoSizeItems = True
                    Me.RadDropDownList1.DropDownListElement.AutoCompleteSuggest.DropDownList.Popup.Font = font

I hope that helps anyone else running into the same issue.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 06 May 2015, 08:21 AM
Hello Keith,

Thank you for writing back.

I am glad that the suggested solution was helpful for achieving your requirement. 

If you have any additional questions, please let me know.

Regards,
Dess
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
DropDownList
Asked by
DJ
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
DJ
Top achievements
Rank 1
Nino
Top achievements
Rank 1
Keith
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or