如何找到游标的位置 [英] How to find position of Cursor

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

问题描述

大家好,

我想找到游标的位置,即光标在文本框中的位置.

预先感谢.

Hi Everyone,

I want to find the position of Cursor, i.e the position of cursor on textbox.

Thanx in advance.

推荐答案

没有内置的方法来获取插入符的位置,但是您可以从选择中推断出来.如果没有选择,则插入标记的位置为选择的开始位置:

There is no built in way to get the caret position, but you can infer it from the selection. If there is no selection, the caret position is the selection start:

Dim lineindex As Integer = myTextBox.GetLineFromCharIndex(myTextBox.SelectionStart)
Dim columnindex As Integer = myTextBox.SelectionStart - myTextBox.GetFirstCharIndexFromLine(myTextBox.GetLineFromCharIndex(myTextBox.SelectionStart))


希望windows.forms.cursor.position [ [^ ]可能帮助您.
Hope windows.forms.cursor.position[^] and this[^] might help you.


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

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