Click here to Skip to main content
15,877,857 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a problem - draging and dropping a Label (in a Form) when I run application then the Form moves to follow it, i.e, this Label is like Title bar of Form. What event of Label should I code to do this? How to code? Thanks.

I'm not 100% sure what you mean by "...the form moves to follow it.", but I think what you are looking for is the anchor property on the label. You can set how it should "stick" to the form. So if you just select that it anchors to the top, it will stay at the top and keep it's location relative to the top when the form is resized. If you say the anchor should be top and left (typically this is the default when you drag and drop a label on the form) it will "stick" to the top left corner. If you set Anchor to Left, Top, Right it will "stick" to the top and stretch/shrink when you resize the form. You should play with it a bit until you find the exact setting you are looking for.

Here[^] is the MSDN for the anchor property.

Hope this helps.
Share this answer
Andrewpeter 1-Sep-12 11:49am    
Thank you, I want to create a custom Title bar control, your idea is useful for me. My vote is 5 for your answer.
Share this answer
Andrewpeter 1-Sep-12 11:50am    
It is great idea which I need, thanks. My vote is 5.

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