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

How to enter a carriage return or line break into a combo box

6 Answers 1004 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 02 Dec 2010, 06:00 PM
I am trying to enter a line break / carriage return in a combo box.  The data in the combo box is long and I want to replace the "-" with a carriage return.  Below is my code that is not working, wondering if this is even possible with the RadComboBox.


PharmacyLocationCollection pharmcol =
new Select()
.From(Tables.PharmacyLocation)
.OrderAsc(PharmacyLocation.Columns.Location)
.ExecuteAsCollection<PharmacyLocationCollection>();
 
 //ddlLocation.Items.Insert(0, new RadComboBoxItem("--select a location--", "0"));
 if (pharmcol.Count > 0)
 {
     int i = 0;
     foreach (PharmacyLocation p in pharmcol)
     {
         string loc = p.Location.ToString();
         loc = loc.Replace("-", "\n");
         ddlLocation.Items.Insert(i, new RadComboBoxItem(loc, p.RXPharmacyID.ToString()));
         i++;
     }
     ddlLocation.Enabled = true;
 }

6 Answers, 1 is accepted

Sort by
0
MV
Top achievements
Rank 1
answered on 03 May 2017, 11:29 PM

Hi Telerik,

Is there a way to add a line break in a combobox?

Thank You!

0
Marin Bratanov
Telerik team
answered on 08 May 2017, 11:22 AM

Hello,

RadComboBox uses an <input type="text"> for its actual input and that does not support new lines.

You can, however, have new lines in the HTML presentation - you can insert <br /> elements in the template of the items: http://docs.telerik.com/devtools/aspnet-ajax/controls/combobox/templates/overview.

Note that the Value should still be a "regular" string without new lines.

Regards,

Marin Bratanov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
MV
Top achievements
Rank 1
answered on 08 May 2017, 04:32 PM

I have a Radcombobox that is populated using the database and also by hard coding some values. It allows for multiple selections and custom text. I would like to add line breaks as well, just like a textbox; you press 'Enter' it adds a line break and saves it to the database.

I need a line break because the information is displayed in a telerik report. If is not possible to add it to the combobox to save it to the database, would it be possible to accomplish a line break in the telerik report?

For example :

John Smith / and Lisa Smith (read this from the database)

John Smith and
Lisa Smith (display this on report by replacing '/' with a line break)

Thanks for your help.

0
MV
Top achievements
Rank 1
answered on 08 May 2017, 06:54 PM

Never mind, I figured it out.

Thank You!

0
N
Top achievements
Rank 1
answered on 09 Feb 2019, 09:15 PM
MV please post your solution. thanks
0
MV
Top achievements
Rank 1
answered on 11 Feb 2019, 04:34 PM

Hi Ken,

Since RadComboBox doesn't support new lines. I had to find a way around it, so I did it using sql.

SELECT Replace(Name, '\', char(13))

Not the perfect solution but it works.

 

 

 

Tags
ComboBox
Asked by
Nick
Top achievements
Rank 1
Answers by
MV
Top achievements
Rank 1
Marin Bratanov
Telerik team
N
Top achievements
Rank 1
Share this question
or