How do I make controls adapt to the user control window width?


I think it’s more a VS than a Rhino Question, but I couldn’t really find the right anwers on google.

I created (my first) custom user control and I placed a button on it.

Here’s a screenshot:

I would like to make the controls adapt to the width of actual control.

So basically, I want the width of the buttons to behave just like the button at the bottom of the Display Settings " Edit “Wireframe” settings…", which always is 100% of the windows width.

And I want to create a scroll button, in case the Content gets to large

Can anyone tell me how I can set this up and/or tell me where I can find documentation on this.


I dont know how you made this so there starts my question.

Is it a form that you made and put a button on it?
Becuase I know how to do it with a form :slight_smile:

Its a Custom Control. You also create it basically trough the VS Designer.
That behavior is probably similar to a form.How do you do that on a form?
I’ll check for the link of the example.

This is the Example provided by Dale Fugier on how to create such a panel (in general)

Private Sub Form1_SizeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged

        '-24 = space left + right
        Button1.Width = Me.Width - 24

    End Sub

This is how to do it with a form.
I’ll try your link :stuck_out_tongue:

Just tested it here. And it works :slight_smile: for VB. But I guess for C# also :slight_smile:

Rather than using the SizeChanged event you can also set the “Anchor” property in the Designer:
Select the button, and press F4 to show the button’s properties. Then, under Layout find the Anchor property. Select the sides that must be anchored - in your case this seems to be Left and Right.

Now, resizing will be as you wished it.


that helps a lot. Takes a while to understand ho VS does it.