图片框上的鼠标事件
我想在图片框中的图像上移动鼠标时查看像素坐标
我已添加此事件 Form.designer.cs
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);
和 Form.cs 中的此方法,
private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
locationtxt.Text = e.X.ToString() + "," + e.Y.ToString();
}
但在表单运行时移动鼠标时我在文本框中看不到任何内容。
我还应该补充什么。 问候,
I want to see my pixel coordinates on moviing my mouse on the image in picture box
I have added this event Form.designer.cs
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);
and this method in Form.cs
private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
locationtxt.Text = e.X.ToString() + "," + e.Y.ToString();
}
but I cann't see anything in textbox on moving my mouse on form runtime.
What should i add further.
regards,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要附加到图片框的事件,而不是 this,并附加到 MouseMove 事件,而不是 MouseDown。
You need to attach to the picturebox's event, not this, and to the MouseMove event, not MouseDown.