Search code examples
c#winformsuser-controls

Resizing a userControl on design view


I created a little UserControl and it works perfectly.

During design view in Visual Studio, I need to modify some things as the control is resized.

Here's the control:

alt text

It's a comboxBox, that is used to display the selected color; and a XAML usercontrol. But that's not quite important.

Basically what I want is that if someone resizes this control during design view in Visual Studio, that little black block remains 1px away from the right side of the control.

I have tried modifying the code in the InitializingComponent() method but it seems that you can't do that.

Thanks for the suggestions and help.


Solution

  • You should set the child control's Anchor to Right.
    For more information, see MSDN.