Solved

Newline in listbox

Posted on 2009-03-31
2
737 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Graphics 2 32
Hey!!!! 1 25
tableview is not updating 1 20
Release Dynamically Allocated Memory in C# 3 38
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
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.
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.

839 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