如何将光标移动到RichTextBox中的指定位置 [英] How To Move The Cursor At A Specified Position In RichTextBox

查看:480
本文介绍了如何将光标移动到RichTextBox中的指定位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表格
在Form1中,我有一个richtextbox
在form2中,我有六个按钮分别用于左箭头键",右箭头键",上箭头键"
,向下箭头键",向上箭头键",主页",结束"

如何使用此按钮programmicaly在richtextbox中的文本之间移动

例如"home"按钮,我编写此代码
richTextBox1.SelectionStart = 0;

如何为其他按钮执行此操作??

tnx

I have two Forms
in Form1 i have a richtextbox
and in form2 i have six button for "left arrow key","right arrow key","up arrow key"
,"down arrow key","up arrow key","home","end"

how i can move between text in richtextbox with this button programmicaly

for example for "home" button i writte this code
richTextBox1.SelectionStart = 0;

how can i do this for other button????

tnx

推荐答案

使用属性System.Windows.Forms.RichTextBox.SelectionStart System.Windows.Forms.RichTextBox.SelectionLength,请参见http://msdn.microsoft.com/en-us/library/system.windowss.forms.richtextbox.aspx [^ ].

不清楚是什么问题.可能这与表单协作有关.最好的方法是在表单类中实现适当的接口.查看我过去的答案:
如何在列表框之间复制所有项目两种形式 [ ^ ].

—SA
Use the properties System.Windows.Forms.RichTextBox.SelectionStart System.Windows.Forms.RichTextBox.SelectionLength, see http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.aspx[^].

Not clear what the problem is. Probably this is about form collaboration. The best way is to implement appropriate interface in form class. See my past answer:
How to copy all the items between listboxes in two forms[^].

—SA


这篇关于如何将光标移动到RichTextBox中的指定位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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