Discovery: The Click event also gets the coordinates of mouse clicks

Source: Internet
Author: User

According to MSDN's instructions and usual habits, we want to get the relative coordinates of mouse click, will use MouseClick and other events, today, accidentally found that the original click event can also.

* * Archaeological achievements of the world of ghosts and spirits.
 * The original Cilck event can also get the current coordinates of the mouse click, MSDN said to use the MouseClick event, haha * The original Click event can also ...
 * However, if an event is raised through the keyboard and not through the mouse, you cannot get it.
 * The right mouse click is not valid.
*/using System;
Using System.Collections.Generic;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Linq;
Using System.Text;

Using System.Windows.Forms;
            namespace WindowsFormsApplication1 {public partial class Form1:form {public Form1 () {
            InitializeComponent ();
                        This.button1.Click + = (s, e) = = {try { MessageBox.Show ("Event Source Type:" + s.gettype (). ToString () + "\ n" + "event parameter type:" + e.gettype (). ToString () + "\ n" + "mouse click X coordinate:" + ((MouseEventArgs) e). X.tostring () + "\ n" + "y-coordinate:" + ((MouseEventArgs) e). Y.tostRing ()); } catch {MessageBox.Show ("You may trigger the event via the ENTER key and cannot get the data.
                    ");
        }
                }; }
    }
}


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.