DropDown Item Height Problem

9 posts, 2 answers
  1. DJ
    DJ avatar
    5 posts
    Member since:
    Nov 2004

    Posted 28 Mar 2011 Link to this post

    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
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 28 Mar 2011 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. DJ
    DJ avatar
    5 posts
    Member since:
    Nov 2004

    Posted 29 Mar 2011 Link to this post

    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.
  5. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 29 Mar 2011 Link to this post

    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
  6. Nino
    Nino avatar
    9 posts
    Member since:
    Apr 2013

    Posted 18 Jul 2013 Link to this post

    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;
                    }

  7. Keith
    Keith avatar
    102 posts
    Member since:
    Mar 2015

    Posted 30 Apr 2015 Link to this post

    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!

  8. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 01 May 2015 Link to this post

    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
     
     
  9. Keith
    Keith avatar
    102 posts
    Member since:
    Mar 2015

    Posted 01 May 2015 in reply to Keith Link to this post

    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.

  10. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 06 May 2015 Link to this post

    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.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready