Syncfusion.Shared.Base
Members 


GridBagLayout Class

Represents the LayoutManager that performs GridBagLayout.
Syntax
'Declaration
 
<ProvidePropertyAttribute("Constraints", System.Windows.Forms.Control)>
<ToolboxItemFilterAttribute("System.Windows.Forms")>
<DescriptionAttribute("Represents the layout manager that arranges control in grid with different size in rows and columns.")>
<ToolboxBitmapAttribute(Syncfusion.Windows.Forms.PopupControlContainer, "ToolboxIcons.GridBagLayout.bmp")>
<DesignerAttribute(Syncfusion.Windows.Forms.Tools.Design.LMDesigner, System.ComponentModel.Design.IDesigner)>
<DesignerCategoryAttribute("Component")>
Public Class GridBagLayout 
   Inherits LayoutManager
   Implements ILayoutManager 
'Usage
 
Dim instance As GridBagLayout
[ProvideProperty("Constraints", System.Windows.Forms.Control)]
[ToolboxItemFilter("System.Windows.Forms")]
[Description("Represents the layout manager that arranges control in grid with different size in rows and columns.")]
[ToolboxBitmap(Syncfusion.Windows.Forms.PopupControlContainer, "ToolboxIcons.GridBagLayout.bmp")]
[Designer(Syncfusion.Windows.Forms.Tools.Design.LMDesigner, System.ComponentModel.Design.IDesigner)]
[DesignerCategory("Component")]
public class GridBagLayout : LayoutManager, ILayoutManager  
Remarks

The GridBagLayout manager creates and manages a grid within the container's layout bounds. Each column and row in this grid can be of different sizes and a component can span more than one cell.

Each component can be assigned weights to determine how to distribute extra space between components. A component can also be anchored to a border / corner of its virtual grid cell. It can also fill its cell.

Note that if you want the child components to be laid out purely based on their weights, set their preferred sizes to be (0,0), specify a non-zero weightX and weigthY, and set their Fill mode to FillMode.Both.

The GridBagConstraints structure specifies all the above constraints associated with a component. Use the SetConstraints method to set the constraints for each component. To exclude a component from layout, call SetConstraints with NULL constraints. Each component has a constraint, which means that there is potential for conflicts in size and boundaries between components. Make sure to manually test the layout design to determine that it behaves appropriately.

Example
The following example shows you how to initialize a GridBagLayout manager with a container control and its children: // Binding a control to the GridBagLayout manager programmatically: this.gridBagLayout1 = new GridBagLayout(); // Set the container control; all the child controls of this container control are // automatically registered as children 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; // You can prevent automatic layout during the layout event. // If you decide to do so, make sure to call gridBagLayout1.LayoutContainer manually: // this.gridBagLayout1.AutoLayout = false; ' Binding a Control to the GridBagLayout manager programmatically: Me.gridBagLayout1 = New GridBagLayout ' Set the target control; all the child controls of this target control are ' automatically registered as children with the manager: Me.gridBagLayout1.ContainerControl = Me.panel1 Me.gridBagLayout1.SetConstraints(Me.button1, New 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, 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: Me.gridBagLayout1.SetConstraints(Me.button3, GridBagConstraints.Empty) ' Modify an exisiting constraint: Dim constraints1 As GridBagConstraints constraints1 = Me.gridBagLayout1.GetConstraintsRef(Me.button1) constraints1.Fill = FillType.Horizontal ' You can prevent automatic layout during the layout event. ' If you decide to do so, make sure to call gridBagLayout1.LayoutContainer manually: ' this.gridBagLayout1.AutoLayout = false;

Also take a look at the project in Tools/Samples/Quick Start%T:Syncfusion.Windows.Forms.Tools.LayoutManager% for an example.

Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         Syncfusion.Windows.Forms.Tools.LayoutManager
            Syncfusion.Windows.Forms.Tools.GridBagLayout

AssemblyVersion

Syncfusion.Shared.Base: 17.4460.0.46

See Also