如何将stringbuilder数据复制到文本框中 [英] How to copy stringbuilder data to a textbox
问题描述
Hello All,
我正在将stringbuilder数据复制到文本框中。
例如我有一个stringbuilder
Hello All,
I am copying stringbuilder data to a text box.
for example i have a stringbuilder
stringbuilder sb=new stringbuilder();
sb.appendline("hello how are you")
sb.appendline("hello how are you")
sb.appendline("hello how are you")
sb.Replace("r\n","<br>")
now I am copying it to textbox
textbox.Text=sb.toString();
但在输出时它插入< br>文本框文本中的标签给出了结果
我需要输出
but on output it inserted <br> tag in textbox text gives result
I need output as
hello how are you<br />
hello how are you<br />
hello how are you
如果我设置为a,这个工作正常div喜欢 div.innerHtml = sb.tostring();
但我需要在文本框中执行此操作
谢谢
This is working fine if I set to a div like div.innerHtml=sb.tostring();
BUT I need to do that in textbox
Thanks
推荐答案
为什么要用
替换行终止符。文本框正确理解行终止符..
以下代码工作正常..
Why you are replacing the line terminator with
. Text box understands the line terminator perfrectly..
The following code works fine..
sb.AppendLine("hello how are you");
sb.AppendLine("hello how are you");
sb.AppendLine("hello how are you");
textBox1.Text = sb.ToString();
有没有理由使用BR Tag?如果你想使用HTML标签你需要使用一个富文本框而不是普通的文本框...
欢呼..
is there any reason to use BR Tag? if you want to use HTML tags you need to use a rich text box not the ordinary text Box...
cheers..
这篇关于如何将stringbuilder数据复制到文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!