如何在文本框中找出光标位置 [英] How to find out cursor position in textbox

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

问题描述

大家好,我正在构建我的自定义记事本,我想找到光标的位置,即line和col.帮助我.

Hi guys, i''m building my custom notepad and i want to find the position of my cursor i.e line and col . Help me.

推荐答案

如果它是多行文本框,则此代码将有所帮助:

If it is a multiline textbox, this code will help:

int line = textBox1.GetLineFromCharIndex(textBox1.SelectionStart) + 1;
int col = textBox1.SelectionStart - textBox1.GetFirstCharIndexOfCurrentLine();


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

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