Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
C#

In my application i am trying to get points in windows form in order join these points to form a specific shape. i gone through lot of search i did't get any answer.
i am new to C# please any one help me how to get points on mouse click event


private void Form1_MouseClick(object sender, MouseEventArgs e)
{
}
Posted

Look at the MouseEventArgs class, and you will find it has a Location property - which tells you where the mouse was when it was clicked.
If you create a class level List or Point structs, then you cna just add the new location to that list for later processing:
C#
private List<Point> points = new List<Point>();
private void Form1_MouseClick(object sender, MouseEventArgs e)
    {
    points.Add(e.Location);
    }
 
Share this answer
 
you can use
C#
private void Form1_MouseClick(object sender, MouseEventArgs e)
        {
            e.Location;
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900