Solved

Newline in listbox

Posted on 2009-03-31
2
736 Views
Last Modified: 2012-08-13
Hi,
How can I make a newline in a listbox?

I get a strange sign in my text box when I use:
\n
and also when I use
Enviorment.newline.

I ad to listbox like this:
listBox2.Items.Add(output);

0
Comment
Question by:Mickeys
2 Comments
 
LVL 6

Assisted Solution

by:HarryNS
HarryNS earned 150 total points
ID: 24026978
Text box and List box are two different controls with different behaviours and purpose.

In text box, the whole content is text... Whether one line or multiple... Completely its single string information.

But In List box, each line is called list item... Each item itself is an object having its own behaviour...
0
 
LVL 4

Accepted Solution

by:
amazingwolf1 earned 350 total points
ID: 24026998
In a list box, do this:
listBox.Items.Add("1");
listBox.Items.Add("");
listBox.Items.Add("2");

as for the textbox:
txt.TextMode = TextBoxMode.MultiLine; // determine its has more then one row
txt.Text = "First row\r\nsecond Row"; // use /r/n  to open a new line

HTH

0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question