Bellow is an example that will show you how to display the cursor's coordinates on a form into a label:
public Form1()
{
InitializeComponent();
//sets the size of the form
this.Size = new Size(500, 500);
//initial text to be displayed in the label
label1.Text = "move your mouse over the form";
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
//update the label text
label1.Text = "( " + e.X + ", " + e.Y + " )";
}
No comments:
Post a Comment