如何逐行获取richtextbox文本 [英] How to get richtextbox text by line

查看:80
本文介绍了如何逐行获取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


这篇关于如何逐行获取richtextbox文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆