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

Is this possible to do ?

5 Answers 66 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Gotcha
Top achievements
Rank 1
Gotcha asked on 07 Jan 2012, 09:03 PM
I'm trying to achieve a different visual style within the combo box...

Notice the word "Yes" and the rest of the wording in a paler color .

Thanks

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Jan 2012, 10:30 AM
Hello,

Try the following code snippet.
CS:
protected void Page_Load(object sender, EventArgs e)
 {
     RadComboBox1.DataSource = CreateDataSource();
     RadComboBox1.DataTextField = "Name";
     RadComboBox1.DataValueField = "ID";
     RadComboBox1.DataBind();
 }
 protected DataTable CreateDataSource()
 {
     DataTable dataTable = new DataTable();
     dataTable.Columns.Add(new DataColumn("ID", typeof(string)));
     dataTable.Columns.Add(new DataColumn("Name", typeof(string)));
     DataRow dr = dataTable.NewRow();
     dr["ID"] = "1";
     dr["Name"] = "<b>FirstName1</b><font color=Red>This is some text!</font>"; //First part in bold and second in red.
     dataTable.Rows.Add(dr);
     DataRow dr2 = dataTable.NewRow();
     dr2["ID"] = "2";
     dr2["Name"] = "<b>FirstName2</b>LastName2";
     dataTable.Rows.Add(dr2);
     return dataTable;
 }

Thanks,
Princy.
0
Gotcha
Top achievements
Rank 1
answered on 15 Jan 2012, 02:01 AM
Sounds great but it generated the html tags inside the value of a text input control...I'm gonna try to use a RadCombo with a Template...
This should be possible...
0
Gotcha
Top achievements
Rank 1
answered on 16 Jan 2012, 02:29 PM
I used a Template Item for the RadCombo... and onItemDataBound, assigned the styles ... this works on the item template, but the selected item cannot be styled since it is in the input field. So I didnt quite achieve the desired output: Ie having Different Style in the Rad Combo ,,,

I can probably  create my own custom combo using labels/div but is there a way of doing this  with the RadCombo?
0
Kevin
Top achievements
Rank 2
answered on 16 Jan 2012, 02:58 PM
Hello Gotcha,

I don't think this would be possible since the text value of the RadComboBox is displayed using an input element, which you can't place html inside, as it will show as is.
0
Gotcha
Top achievements
Rank 1
answered on 17 Jan 2012, 12:23 PM
Thanks Princy ... are you from telerik team...just curious
Tags
ComboBox
Asked by
Gotcha
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Gotcha
Top achievements
Rank 1
Kevin
Top achievements
Rank 2
Share this question
or