Get form coordinates of a custom control
In Winforms, I have implemented a cus开发者_JS百科tom object with a draw method, which is called by Form_Paint. I now want to be able to get the coordinates of this object after being drawn to the form, for the sake of a Move procedure in the works. I have tried using object.Location, object.Left, and object.Top, but these just give 0,0. I then tried object.Size to test, and it gave me the size of the form.
How can I get the location of my runtime object on the form? Thanks
Try using
Point objLocation= cusObject.FindForm().PointToClient(
cusObject.Parent.PointToScreen(cusObject.Location));
精彩评论