003_My003App_显示鼠标位置

Code:

private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            string X = e.X.ToString();    /*定义X的坐标*/
            string Y = e.Y.ToString();    /*定义Y的坐标*/
            lblMouseStatus.Text = "鼠标位置(" + X + "," + Y + ")";
            /*将鼠标的坐标赋值给标签并显示出来*/
        }

 

参考下图:

[C#]003_My003App_显示鼠标位置_职场