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

DropDownList HTML items text not working

2 Answers 78 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Leandro
Top achievements
Rank 1
Leandro asked on 24 Aug 2018, 03:48 PM
Hey guys, I've got a problem, the selected item text just don't work with html formatted text. Any help? I'm using telerik 2015

2 Answers, 1 is accepted

Sort by
0
Leandro
Top achievements
Rank 1
answered on 24 Aug 2018, 03:59 PM
Ok, I managed to solve it just by setting the style to dropdownlist, I don't need it to be dropdown anyway. But the problem stills exists.
0
Accepted
Hristo
Telerik team
answered on 28 Aug 2018, 12:48 PM
Hello Leonardo,

Thank you for writing.

I am not sure how you ended up with the formatted text in the editor of the RadDropDownList control. This editor actually extends the standard Microsoft text box and it cannot be used with HTML-like formatted text. You can try handling the VisualListItemFormatting event of the control and only format the item displayed in the list when it is open: 
public partial class RadForm1 : Telerik.WinControls.UI.RadForm
{
    public RadForm1()
    {
        InitializeComponent();
 
        this.radDropDownList1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;
        this.radDropDownList1.VisualListItemFormatting += RadDropDownList1_VisualListItemFormatting;
    }
 
    private void RadDropDownList1_VisualListItemFormatting(object sender, Telerik.WinControls.UI.VisualItemFormattingEventArgs args)
    {
        string text = string.Format("<html><strong>{0}</strong></html>", args.VisualItem.Text);
        args.VisualItem.Text = text;
    }
}

I hope this will help. Let me know if you have other questions.

Regards,
Hristo
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
DropDownList
Asked by
Leandro
Top achievements
Rank 1
Answers by
Leandro
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or