I have a CSV
file which holds various items. Some of these items I put into a combobox. How can I put a newline and/or tab in the CSV
file so it will show up as a newline/tab inside the combobox? I have tried \t
and \n
but it just shows those in the combobox.
Asked
Active
Viewed 2,491 times
3

Csharp
- 2,916
- 16
- 50
- 77

user1620479
- 85
- 5
-
How are you putting the data into a ComboBox? Is this WinForms or ASP .NET? – rhughes Jul 10 '13 at 19:09
-
Sadly you can't. Not using the standard html input. – gustavodidomenico Jul 10 '13 at 19:11
1 Answers
2
The base ComboBox
doesn't support special characters like this for its display, they will simply be ignored. If you need this type of functionality you'll need to override the OnDrawItem
method and draw those items on your own - I do not recommend this. Another option would be to use a more advanced ComboBox
from a company like Telerik or Infragistics.

Mike Perrenoud
- 66,820
- 29
- 157
- 232
-
1This is mostly right. You probably don't want to override `OnPaint` because you don't want to take *all* of the drawing into your own hands. That would include things like the drop-down arrow that are best left to be painted by the system. Fortunately, the ComboBox control was explicitly designed to support owner-draw, which lets you take *some* but not all of the drawing into your own hands. In this case, you want to override `OnDrawItem`. I wrote up a very detailed answer [here](http://stackoverflow.com/a/15516029/366904) in response to a challenge that this could not be done in WinForms. – Cody Gray - on strike Jul 10 '13 at 19:22
-
@CodyGray, fantastic correction! Thank you very much. I'll edit the answer. Oh, and it can be done, I've done it as well. I'm going to jump over and have a look at your answer! – Mike Perrenoud Jul 10 '13 at 19:25