方法1--直接獲取
//取得目前滑鼠位置 Console.WriteLine("x:" + System.Windows.Forms.Cursor.Position.X); Console.WriteLine("y:" + System.Windows.Forms.Cursor.Position.Y);
方法2--透過事件新增
private void pictureBox2_MouseMove(object sender, MouseEventArgs e) { label2.Text = "x:" + e.Location.X; label3.Text = "y:" + e.Location.Y; }
測試環境:c#2015
沒有留言:
張貼留言