wpf richtextbox 检查插入符是否在最后一行或计算它有多少行
我试图在富文本框中找出插入符是否位于最后一行。这可能吗?
注意:最后我还添加了:或计算它有多少行,这是因为在miscrosoft论坛中有一个用于检测插入符在哪一行的示例。
谢谢
I am trying to find out in a richtext box whether the caret is position in the last line. Is this possible?
NOTE: At the end I also added: or count how many lines it has, this is because in the miscrosoft forum there is an example for detecting in which line the caret is.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
请验证 msdn 链接
http:// Social.msdn.microsoft.com/Forums/en/wpf/thread/667b5d2a-84c3-4bc0-a6c0-33f9933db07f
如果您确实想知道插入符号的行号,您可以执行以下操作(可能需要一些调整):
Please verify the msdn link
http://social.msdn.microsoft.com/Forums/en/wpf/thread/667b5d2a-84c3-4bc0-a6c0-33f9933db07f
If you really wanted to know the line number of the caret, you could do something like the following (probably needs some tweaking):
获取行数的代码:
The code to get the number of lines:
我找到了解决办法。也许有更简单的方法,如果有请告诉我
//这段代码来自
//http://social.msdn .microsoft.com/Forums/en/wpf/thread/667b5d2a-84c3-4bc0-a6c0-33f9933db07f
I have found a solution. Maybe there is a simpler way, if so please let me know
//This code comes from
//http://social.msdn.microsoft.com/Forums/en/wpf/thread/667b5d2a-84c3-4bc0-a6c0-33f9933db07f
我尝试了代码,但并不总是给出正确的结果。
一种聪明的方法是这样的
I tried the code and is not giving correct results always.
One smart way to do it is this