vs2008/vs2010 在 TextBox 中有插入符号位置更改事件吗? [英] does vs2008/vs2010 has a caret position changed event in TextBox?

查看:34
本文介绍了vs2008/vs2010 在 TextBox 中有插入符号位置更改事件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要注意 TextBox 内的插入符号位置;有这个活动吗?我不想为此使用计时器(例如,如果位置发生变化,则每 10 毫秒检查一次).

I need to keep an eye on caret position inside a TextBox; is there an event for this? I don't want to use timer for this (eg. check every 10ms if position changed).

我使用的是 Windows 窗体.

I am using Windows Forms.

推荐答案

希望这会有所帮助.我在鼠标移动上做到了这一点

Hope this will help. I have done this on Mouse Move

private void txtTest_MouseMove(object sender, MouseEventArgs e)
{
   string str = "Character{0} is at Position{1}";
   Point pt = txtTest.PointToClient(Control.MousePosition);
   MessageBox.Show(
      string.Format(str
      , txtTest.GetCharFromPosition(pt).ToString()
      , txtTest.GetCharIndexFromPosition(pt).ToString())
   );
}

这篇关于vs2008/vs2010 在 TextBox 中有插入符号位置更改事件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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