ComponentOne Sizer for WinForms
In This Topic
    Bands
    In This Topic

    The Sizer panel has a grid layout which consists of row and column bands. These bands are automatically recalculated when the Sizer control is resized, and the contained controls are relocated to their new places. You can set up bands at design time and through, and configure them to act as splitters or keep their size constant when the control is resized.

    Add Bands

    Sizer allows various ways to add row and column bands using the RowCollection and ColumnCollection classes. It provides the Insert method to add a band at a specific location by specifying the positions where the bands are to be inserted as showcased in the following code. 

    C#
    Copy Code
    //add a new row band at index 1
    c1Sizer1.Grid.Rows.Insert(1);
    //add a new column band at index1
    c1Sizer1.Grid.Columns.Insert(1);
    

    Alternatively, you can increment the value of the Count property to add a new band to the Sizer control as shown in the following code snippet.

    C#
    Copy Code
    //set count value greater than current count value
    c1Sizer1.Grid.Rows.Count = 2;
    c1Sizer1.Grid.Columns.Count = 2;
    

    In addition, you can create bands at design time using the C1Sizer Grid Editor. For more information, see C1Sizer Grid Editor.

    Back to Top 

    Delete Bands

    To delete a particular row or a column band from the grid, you can use Remove method of the RowCollection or ColumnCollection class, respectively. The Remove method takes the index of the column/row band as its parameter and deletes the specified band.

    The following code shows how bands can be deleted from the Sizer control.

    C#
    Copy Code
    //remove row band at index 1
    c1Sizer1.Grid.Rows.Remove(1);
    //remove column band at index 1
    c1Sizer1.Grid.Columns.Remove(1);
    

    Besides, you can also delete the bands using the C1Sizer Grid Editor. For more information, see C1Sizer Grid Editor.

    Back to Top 

    Delete Unused Bands

    Getting rid of unused bands from the grid layout can be a tedious task. But, Sizer makes it easier by providing the AutoGrid option. This option clears any bands that do not have any controls attached to them. To use this option to clear unused bands from the grid, right-click the Sizer control and select AutoGrid from the context menu.

    The following image shows the appearance of the Sizer control after removing the unused bands.

     Deleting unused bands

    Back to Top 

    Set Band Size

    Sizer allows you to set the size of the row and column bands by using Size property of the Row and Column classes, respectively. Here, the size represents the row height (in pixels) for a row band, and column width (in pixels) for a column band.

    The following code snippet shows how to set the size of a row and a column band in Sizer.

    C#
    Copy Code
    //set size of a row band
    c1Sizer1.Grid.Rows[1].Size = 10;
    //set size of a column band
    c1Sizer1.Grid.Columns[1].Size = 10;
    

    You can also set the size of the bands at design time using the C1Sizer Grid Editor. For more information, see C1Sizer Grid Editor.

    Back to Top 

    Fixed-Size Band

    You can designate certain bands as fixed size, so they do not resized. For example, you might want to allow only the text box placed in the first band to be resized vertically, and keep the height of all others constant by setting IsFixedSize property of the Band class to true.

    The following code snippet shows how to create fixed-size row and column bands in Sizer control.

    C#
    Copy Code
    //create fixed size row band
    c1Sizer1.Grid.Rows[1].IsFixedSize = true;
    //create fixed size column band
    c1Sizer1.Grid.Columns[1].IsFixedSize = true;
    

    Alternatively, you can also use the C1Sizer Grid Editor to create fixed-size bands at the design time. For more information, see C1Sizer Grid Editor.

    Back to Top 

    Create Splitter Band

    Splitter bands are the row and column bands that can be resized at run time using the mouse. Each band (row or column) on the grid can be configured to act as a splitter. You can create a splitter band by setting IsSplitter property of the Band class to True. Additionally, you can set the width of the splitter band by using SplitterWidth property of the C1Sizer class in case the controls are too close to each other or too far apart.

    The following code snippet demonstrates how to create a splitter band in Sizer.

    C#
    Copy Code
    //create row band splitter
    c1Sizer1.Grid.Rows[1].IsSplitter = true;
    //create column band splitter
    c1Sizer1.Grid.Columns[1].IsSplitter = true;
    

    Back to Top