Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I am creating some controls at runtime, and I have options for drag and drop with runtime created controls. When I drag and drop from one place to another place I want to know the new X,Y location of that control. How can I get this please? Sample code appreciated.
Posted
Updated 1-Nov-10 7:02am
v2
Comments
Sergey Alexandrovich Kryukov 11-Apr-13 12:08pm    
Honestly, I just don't want to bring your abuse to the attention of the community, because I don't want you to loose your account which may happen on several abuse reports. Your abuse is minor so far, but please be careful: some of your "Solution" posts were not answers; they could be comments; and I just removed your non-question. The abuse reports on inappropriate posts are pretty much safe; they will lead to auto-deletion of such posts, but if you irritate people with systematic abuse, they will feel spammed and report on the account, with the risk of it cancellation. A number of people posting fake "answers" already lost their account. I don't think it should happen to you, because they were just cheating, and you just need to be more accurate...
Good luck,
—SA

controlid.Top = the distance from top of control to top of form.
controlid.Left = distance from left of control to left of form.
thats your Y and your X respectivly.

there are also Bottom and Right properties. they are Get and Set
 
Share this answer
 
Comments
Simon_Whale 3-Nov-10 11:29am    
nice answer
MsgBox(String.Format("Mouse X:{0}, Y:{1}", Control.MousePosition.X, Control.MousePosition.Y))
 
Share this answer
 
Comments
Simon_Whale 3-Nov-10 11:30am    
thats mouse pointer rather than the top and left of a recently dropped control

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900