Get form location
How can I get the position of a form? Alternatively, is it possible to get a button's position relative to the screen instead of the parent form?
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.

joakim wireen46 reputationPosted Apr 7, 2009, 1:22 AM EDT
Pieter De Decker22 reputationPosted Apr 7, 2009, 2:37 AM EDT
Point popupLocation = new Point(this.Location.X + btnRVi.Location.X, this.Location.Y + btnRVi.Location.Y + btnRVi.Height);
However, the menu is not positioned correctly. Is there anything I have overlooked? Could it be the title bar of my form?
joakim wireen46 reputationPosted Apr 12, 2009, 7:01 AM EDT
No, your doing it wrong.
Point FormLocation = this.Location; Point ButtonLocation = this.button1.Location; Point PopupLocation = new Point(FormLocation.X + ButtonLocation.X + this.button1.Width, FormLocation.Y + ButtonLocation.Y + this.button1.Height);Form's location + Buttons location + the the width/height of the button.
Pieter De Decker22 reputationPosted Apr 12, 2009, 11:23 AM EDT