We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add a layout manager component to a form

Platform: WinForms |
Control: XPToolbar |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014

 

Using the designer:

Just drag-and-drop the appropriate layout manager component onto your form. You can optionally drop the component on the container that you want to layout and the design-time will automatically set the ContainerControl property in the layout manager.

You can then configure the layout manager by changing its properties via the designer’s property grid. The layout manager will also provide some extended properties on the child controls that you can set via the control’s property grid.

In Code:

This example shows how to initialize a GridBagLayout programmatically. Take a look at the class reference for the other layout managers, for example, the code on how to initialize them programmatically.

[C#] // Binding a Control to the GridBagLayout manager programaitcally this.gridBagLayout1 = new GridBagLayout();     // Set the container control; Doing this will automatically register all the child controls of this container control // with the manager. this.gridBagLayout1.ContainerControl = this.panel1;

this.gridBagLayout1.SetConstraints(this.button1,  new GridBagConstraints(0, 0, 3, 1, 1, 0.2, AnchorTypes.Center, FillType.Both, new Insets(0, 0, 0, 0), 0, 0, false));

this.gridBagLayout1.SetConstraints(this.button2,  new GridBagConstraints(0, 1, 1, 3, 0.2, 0.6, AnchorTypes.Center, FillType.Both, new Insets(0, 0, 0, 0), 0, 0, false));

// Exclude button3 from layout this.gridBagLayout1.SetConstraints(this.button3, GridBagConstraints.Empty);      // Modify an exisiting constraint. GridBagConstraints constraints1 = this.gridBagLayout1.GetConstraintsRef(this.button1); constraints1.Fill = FillType.Horizontal;

[VB.NET] ' Binding a Control to the GridBagLayout manager programaitcally Me.gridBagLayout1 = New GridBagLayout()   ' Set the container control; Doing this will automatically register all the child controls of this container control ' with the manager. Me.gridBagLayout1.ContainerControl = Me.panel1   Me.gridBagLayout1.SetConstraints(Me.button1,  GridBagConstraints(0,0,3,1,1,0.2,AnchorTypes.Center,FillType.Both,New Insets(0,0,0,0),0,0,False))   Me.gridBagLayout1.SetConstraints(Me.button2,  GridBagConstraints(0,1,1,3,0.2,0.6,AnchorTypes.Center,FillType.Both,New Insets(0,0,0,0),0,0,False))   ' Exclude button3 from layout Me.gridBagLayout1.SetConstraints(Me.button3, GridBagConstraints.Empty)   ' Modify an exisiting constraint. Dim constraints1 As GridBagConstraints =  Me.gridBagLayout1.GetConstraintsRef(Me.button1) constraints1.Fill = FillType.Horizontal

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon