Click here to Skip to main content
15,749,352 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a list from of words in a textbox, separated using a comma. But want every new word to be put on a new line i.e.

Milk, egsgs,bread --- written as


This is the code I have ...
//    string[] lines = processesTextBox.Text.Split(new[] { Environment.NewLine },StringSplitOptions.None);

When I run the code - the text is all still on one line

What I have tried:

Updated 8-May-18 4:46am

1 solution

First off, unless it is a multiline textbox, then you can't do it at all: a "normal" textbox only ever shows a single line of text, and uses an ellipsis "..." to indicate "more text to the left / right"

You could set it to a multiline textbox, and just use string.Replace:
myTextBox.Text = myTextBox.Text.Replace(",", Environment.NewLine);
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900