Windows Develop Bookmark and Share   
 index > Windows Forms General > I need help in finding the cursor
 

I need help in finding the cursor

I am making a chess program using Visual C#. I have a chess board drawn and the pieces placed, and I want the players to be able to click on the different grid boxes to higlight them. To do this, I need to get the coordinates of the Windows cursor after it has clicked on the picture box. How do I get the location of the cursor when it is over the picture box and convert into a Point variable that can be compared to points in the picture box?

HSauce  Tuesday, December 02, 2008 6:43 AM
I believe this (should) work...


Code Snippet

public void MouseDown(object sender, MouseEventArgs e)

{
//e.X and e.Y should be the mouse location when the MouseDown event occured.
Point mouseLocation = new Point(e.X,e.Y);
}

atkinsonben  Tuesday, December 02, 2008 11:10 AM
I believe this (should) work...


Code Snippet

public void MouseDown(object sender, MouseEventArgs e)

{
//e.X and e.Y should be the mouse location when the MouseDown event occured.
Point mouseLocation = new Point(e.X,e.Y);
}

atkinsonben  Tuesday, December 02, 2008 11:10 AM
Thanks a lot it worked.

HSauce  Tuesday, December 02, 2008 11:00 PM

You can use google to search for other answers

Custom Search

More Threads

• how can i make a form visible based on a condition ?
• C# Having trouble setting the form icon!
• System.Windows.Forms.SendKeys.Send and SHIFT
• Some listbox selection questions
• drag the panel
• Taskbar applications
• Installing .net on win ME or win 98
• Using ListView SelectedIndexChanged Event to Show Forms
• Embed Application in C# Windows.Forms.Form
• element coordinates from webBrowser class