i want to display x and y mouse position of mouse under my windows form application

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Akki44226
    New Member
    • Sep 2019
    • 1

    i want to display x and y mouse position of mouse under my windows form application

    "I have to text box to display mouse's x and y position i want to display it in textboxes.

    I am new IT student i have no idea about this...so any body can help me.."

    I Want to Retrive x and y Postion of my mouse arrow, I want to display it in my textboxes.
    Attached Files
    Last edited by gits; Sep 24 '19, 02:16 PM. Reason: obviously double post
  • SioSio
    Contributor
    • Dec 2019
    • 272

    #2
    Add MouseMove event handler.
    Code:
            public Form2()
            {
                InitializeComponent();
                //Get Mouse Pointer
               this.MouseMove += new MouseEventHandler(Mouse_Move);
            }
            private void Mouse_Move(object sender, EventArgs e)
            {
            	
            	//X-ray
    			int x = System.Windows.Forms.Cursor.Position.X;
    			//Y-ray
    			int y = System.Windows.Forms.Cursor.Position.Y;
    			this.textBox1.Text = x.ToString();
    			this.textBox2.Text = y.ToString();
            }

    Comment

    Working...