Sizer for WinForms
コントロールの追加

With Sizer, you can easily add controls to the form to create a form layout. Each added control can be positioned over a single grid cell or it may span over multiple cells.

Let us discuss how to add controls to the Sizer control at design time and through code.

Add Controls at design time

You can add controls to Sizer at design time without writing a single line of code. For more information on how to add controls at design time, see Create Layout at design time section in the Quick Start topic.

Add Controls using code

You can add controls to the Sizer and position them within the grid layout through code as well.

Follow the given steps to add controls to Sizer.

  1. Subscribe to Form1_Load event from the Properties window.
  2. Switch to the code view and add the following code to the event handler created for Form1_Load event for adding band.
    C#
    コードのコピー
    Type your example code here. It will be automatically colorized when you switch to Preview or build the help system.
    
    For more information on how to add bands using code, see Add Bands section in Bands topic.
  3. Initialize a control and add it to the Sizer control using the following code.
    C#
    コードのコピー
    Type your example code here. It will be automatically colorized when you switch to Preview or build the help system.
    
  4. Get the bounds of the cells where you wish to position the control within the grid using GetCellBounds method of the C1Sizer class as demonstrated in the following code snippet.
    C#
    コードのコピー
    Type your example code here. It will be automatically colorized when you switch to Preview or build the help system.
    
  5. Set the bounds of the control to the bounds of the cell range obtained using the GetCellBounds method, as showcased in the following code.
    C#
    コードのコピー
    Type your example code here. It will be automatically colorized when you switch to Preview or build the help system.
    

This adds the control to the desired location within the grid. You can observe that the Sizer snaps the controls to the specified position on the grid, and automatically resizes the control when the form is resized.