如何将光标移动到所需行的开头 [英] How to move the cursor to the beginning of the required line

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

问题描述

我有一个名为txtgoto的文本框。

如果我在txtgoto中输入任意数字并单击按钮btnGoToLine,光标应该转到文本框txtMain中所需的

行和在该行的开头闪烁。



Ca任何人都能找到这个问题的代码

I have a text box called txtgoto.
If I enter any number in txtgoto and click button btnGoToLine the cursor should goto the required
line in the textbox txtMain and blink in the beginning of that line.

Ca anyone get me a code for this problem

推荐答案

如果这是winforms,那么你需要使用Select方法:

If this is winforms, then you need to use the Select method:
int pos = myTextBox.GetFirstCharIndexFromLine(7);
if (pos >= 0) 
   {
   myTextBox.Select(pos, 0);
   }

将其设置为第七行的开头

Would set it to the start of line seven


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

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