The selected answer is technically correct taking into account the specifics of the question: there is no such property in the .NET environment.
But if you want to get such a property, then this is a control extension that will do the trick. Yes, it uses screen coordinates, but given the general nature of the message header, I am sure that some users landing on this page may find this useful.
By the way, I spent a couple of hours trying to do this without screen coordinates, going through all the control parents. I can never combine these two methods. Perhaps this is due to Hans Passant's comment on the OP about how Aero lies in relation to the size of the window.
using System; using System.Drawing; using System.Windows.Forms; namespace Cambia { public static class ControlExtensions { public static Point FormRelativeLocation(this Control control, Form form = null) { if (form == null) { form = control.FindForm(); if (form == null) { throw new Exception("Form not found."); } } Point cScreen = control.PointToScreen(control.Location); Point fScreen = form.Location; Point cFormRel = new Point(cScreen.X - fScreen.X, cScreen.Y - fScreen.Y); return cFormRel; } } }
source share