如何将文本发送到下一行 [英] How to sent text to next line
本文介绍了如何将文本发送到下一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文本框中的单词列表,使用逗号分隔。但是希望每个新单词都换上新的一行即
牛奶,egsgs,面包---写成
牛奶
鸡蛋
面包
而不是
这是我的代码...
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
Milk
Eggs
Bread
instead
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:
processesTextBox.Text.Split(',');
推荐答案
首先,除非它是一个多行文本框,否则你根本不能这样做:普通文本框只显示一行文字,并使用省略号...表示左/右文字更多
你可以将它设置为多行文本框,并使用string.Replace:
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);
这篇关于如何将文本发送到下一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文