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

Font & Focus

3 Answers 94 Views
FontDropDownList
This is a migrated thread and some comments may be shown as answers.
golnar
Top achievements
Rank 1
golnar asked on 14 Apr 2016, 11:27 AM

How can I change the font of DropDownList items?

How can I change focused color of DropDownList?

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Apr 2016, 08:44 AM
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.
0
golnar
Top achievements
Rank 1
answered on 18 Apr 2016, 09:49 AM
I did what you said to change RadDropDownList focus color, but it had no effect. My RadDropDownList focus color is not changed.
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Apr 2016, 10:14 AM
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 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.
Tags
FontDropDownList
Asked by
golnar
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
golnar
Top achievements
Rank 1
Share this question
or