Font & Focus

4 posts, 1 answers
  1. golnar
    golnar avatar
    2 posts
    Member since:
    Apr 2016

    Posted 14 Apr Link to this post

    How can I change the font of DropDownList items?

    How can I change focused color of DropDownList?

  2. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 15 Apr Link to this post

    Hello Golnar,

    Thank you for writing.

    It is suitable to use the VisualListItemFormatting event in order to customize the dropdown items and change the font: http://docs.telerik.com/devtools/winforms/dropdown-listcontrol-and-checkeddropdownlist/dropdownlist/formatting-items

    As to the focus color, you can subscribe to the RadDropDownList.GotFocus event and set the desired ForeColor to the DropDownListElement.EditableElement.TextBox.TextBoxItem. It is necessary to reset the color in the RadDropDownList.LostFocus event:
    public Form1()
    {
        InitializeComponent();
     
        this.radDropDownList1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown;
        this.radDropDownList1.GotFocus += radDropDownList1_GotFocus;
        this.radDropDownList1.LostFocus += radDropDownList1_LostFocus;
    }
     
    private void radDropDownList1_LostFocus(object sender, EventArgs e)
    {
        this.radDropDownList1.DropDownListElement.EditableElement.TextBox.TextBoxItem.ForeColor = Color.Black;
    }
     
    private void radDropDownList1_GotFocus(object sender, EventArgs e)
    {
        this.radDropDownList1.DropDownListElement.EditableElement.TextBox.TextBoxItem.ForeColor = Color.Red;
    }
     
    Font f = new Font("Arial",10f, FontStyle.Italic);
     
    private void radDropDownList1_VisualListItemFormatting(object sender, Telerik.WinControls.UI.VisualItemFormattingEventArgs args)
    {
        args.VisualItem.Font = f;
    }

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

     Regards,
    Dess
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. golnar
    golnar avatar
    2 posts
    Member since:
    Apr 2016

    Posted 18 Apr in reply to Dess Link to this post

    I did what you said to change RadDropDownList focus color, but it had no effect. My RadDropDownList focus color is not changed.
  5. Answer
    Dess
    Admin
    Dess avatar
    1601 posts

    Posted 18 Apr Link to this post

    Hello Golnar,

    Thank you for writing back. 

    The provided solution is applicable to the RadDropDownStyle.DropDownList. The RadDropDownList.DropDownStyle property determines if the text area at the top of the control can be edited. A setting of DropDown allows editing and TextBox is hosted in the editable part. Setting the DropDownListElement.EditableElement.ForeColor will affect the color in both modes. I have attached my sample project for your reference.

    I hope this information helps. If you have any additional questions, please let me know.

     Regards,
    Dess
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top