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?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pieter De DeckerPosted Apr 12, 2009, 3:23 PM
joakim wireenPosted Apr 12, 2009, 11:01 AM
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 DeckerPosted Apr 7, 2009, 6:37 AM
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 wireenPosted Apr 7, 2009, 5:22 AM