Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Quick question

Suppose you design a UserControl and add a couple buttons on it (simple example).

You then use the Visual Studio Designer, create a new Form, and add the homemade UserControl (with the two buttons).

Is there a way to reposition controls within the UserControl while it is on the Form visually (without programming)? The two buttons are declared Public.
Posted

If you mean change their position in the designer, no. You must change them in the user control if you want to use the designer.
 
Share this answer
 
no there isnt, however if you positioning is achievable via docking and anchoring then it will update as you resize the custom control itself.

alternatively, if you expose properties on the custom control that directly modify the child control positions in the property setters then you should (though i haven't checked) be able to move the child controls through the properties window
 
Share this answer
 
actually I found a technique.

you have to create a designer class by inheriting from ParentControlDesigner.

You override Initialize(IComponent component), and add the components you want to be able to resize via calling EnableDesignMode.

You decorate your usercontrol with the customer designer:

[Designer(typeof(MyCustomDesigner))]

And it works.

Pretty cool.
 
Share this answer
 
Comments
GParkings 2-Sep-11 7:49am    
You should post some sample code in either an article or tips & tricks forum. Others would be interested to see how this can be done

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