如何控制鼠标,移动并悬停到某个控件上方?

cherry_j 2007-10-15 10:51:04
如何控制鼠标,移动并悬停到某个控件上方?

如何移动鼠标到textbox上方?
...全文
134 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
w_8023 2010-12-09
  • 打赏
  • 举报
回复
怎么能在pictureBox上鼠标悬停在上面2秒时出现小提示呢??
xiaobingbing 2007-10-15
  • 打赏
  • 举报
回复
上,正解
KeequenLiu 2007-10-15
  • 打赏
  • 举报
回复
问题1:
//锁定鼠标活动范围:
void LockCursor()
{
this.Cursor=new Cursor(Cursor.Current.Handle);
Cursor.Position=new Point(Cursor.Position.X,Cursor.Position.Y);
Cursor.Clip=new Rectangle(this.Location,this.size);//这里是窗体的大小.即鼠标只能在窗体范围内活动.如果要改成控件,只改动this.Location,this.size.
}
如果是,textBox txtbox:则:
void LockCursor()
{
this.Cursor=new Cursor(Cursor.Current.Handle);
Cursor.Position=new Point(Cursor.Position.X,Cursor.Position.Y);
Cursor.Clip=new Rectangle(txtbox.Location,txtbox.size);
}
希望对你有用!
流浪河 2007-10-15
  • 打赏
  • 举报
回复
我不知道你说的上方是什么 是否是焦点?试下 TextBox1.Focus();
cherry_j 2007-10-15
  • 打赏
  • 举报
回复
???
北京的雾霾天 2007-10-15
  • 打赏
  • 举报
回复

private void button1_Click(object sender, EventArgs e)
{
Point point = this.textBox1.PointToScreen(new Point(this.textBox1.Width / 2, this.textBox1.Height / 2));
Cursor.Position = point;

WAKU 2007-10-15
  • 打赏
  • 举报
回复
API
SetCursor
cherry_j 2007-10-15
  • 打赏
  • 举报
回复
不是锁定,只要让鼠标自动移到textbox上方即可

110,570

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧