How to call the function?

advertisements

I need to get the position of the mouse on click in a form, and save the x and y coordinates. I made this simple function:

 public void kokot (MouseEventArgs e)
 {
    x = e.X;
    y = e.Y;
    this.Invalidate();
 }

How can I call it? When I try kokot() it doesn't work of course, because there are no arguments. So what arguments should I use in this case? Thanks in advance for any help.


public Form1()
    {
        InitializeComponent();
        this.MouseClick += new MouseEventHandler(Form1_MouseClick);
    }

    private void Form1_MouseClick(object sender, MouseEventArgs e)
    {
        int x = e.X;
        int y = e.Y;
        this.Invalidate();
    }