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


#1

Hi,

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.

BUTTONS:
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.

SCROLL
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.

Thanks
Karl


#2

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:


#3

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.


#4

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

https://github.com/dalefugier/SampleCsPanel


#5
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:


#6

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


(Menno Deij - van Rijswijk) #7

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.


#8

Thanks,

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

Karl