如何逐行获取richtextbox文本
问题描述:
标题是什么:
我的意思是你可以做普通文本框的
:
GetLineText()
What the title says:
I mean
with normal textbox you can do:
GetLineText()
你如何为richtextbox做这件事?
how can you do it for richtextbox?
答
什么标题说:
我的意思是你可以做普通文本框的
:
GetLineText()
What the title says:
I mean
with normal textbox you can do:
GetLineText()
你如何为richtextbox做这件事?
how can you do it for richtextbox?
嗨 Mordechai01,
$
您可以尝试以下代码。
Hi Mordechai01,
You can may try the following code.
string richText = new TextRange(testrich.Document.ContentStart, testrich.Document.ContentEnd).Text;
String[] lines = richText.Split(new[] { Environment.NewLine }
, StringSplitOptions.RemoveEmptyEntries);
foreach (var line in lines)
{
MessageBox.Show(line);
}
最好的问候,
Yong Lu
Best Regards,
Yong Lu