Gilad Naaman
Gilad Naaman

Reputation: 6550

Getting mouse-position relatively to a control

I'm trying to find a way to get the mouse position relatively to the upper left corner of a control, is there a way to accomplish that?

Upvotes: 5

Views: 14083

Answers (2)

manji
manji

Reputation: 47978

yourControl.PointToClient(Control.MousePosition)

Upvotes: 3

David Heffernan
David Heffernan

Reputation: 613451

Call MyControl.PointToClient() passing Cursor.Position.

Upvotes: 19

Related Questions