如何在富文本框中的文本光标之前获取字符? [英] How can we gain characters before the text cursor in rich text box?

查看:500
本文介绍了如何在富文本框中的文本光标之前获取字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我是C#编程的新手.
我在Richtextbox上遇到问题,我不知道如何在文本光标之前获取文本.我对此一无所知.所以请某人帮助我.
阅读感谢.
真诚的.

Hi everyone,
I am new in programming C#.
I am having a problem with richtextbox,I don''t know how to get the text before the text cursor. I have no idea about this. So plz someone help me.
Thx for reading.
sincerely.

推荐答案

您可以通过SelectionStart和SelectionLength属性间接获取光标位置.

SelectionStart始终位于任何选定文本的左上方,而SelectionLength是选定字符的数量.

如果没有选择,则获取当前光标位置,然后为零.该值是从文本开头开始的字符数,因此很容易确定光标之前的字符!
You can get the cursor position indirectly, via the SelectionStart and SelectionLength properties.

The SelectionStart is always the top left of any selected text, and the SelectionLength is the number of character selected.

If there is no selection, you get the current cursor position, and zero. The value is number of characters from the start of the text, so it is simple to work out what characters are before the cursor!


If there is no selection, you get the current cursor position, and zero. The value is number of characters from the start of the text, so it is simple to work out what characters are before the cursor!<br />


如果没有选择,我将获得当前光标的位置,并且光​​标之前的字符为零,这不是I ??
我不明白.
先生,因为我的英语不好.
谢谢我.
真诚的.


If there is no selection, I will get the current cursor position, and characters before cursor is zero,won''t I??
I don''t understand.
Sr for my bad English.
Thx for relying me.
Sincerely.


非常感谢.
我现在了解你的想法.
但是richtext有方法可以让Richtext中的aline开始,对吗?
sr是我编程的坏技能.
谢谢^^.
Thx alot.
I understand ur idea now.
But richtext has method to get the start of aline in Richtext,dosen''t it??
sr for my bad skill in programming.
Thx ^^.


这篇关于如何在富文本框中的文本光标之前获取字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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