FlexGrid for WinForms | ComponentOne
Row / Sizing
In This Topic
    Sizing
    In This Topic

    Set Row Height

    FlexGrid provides DefaultSize property of the RowCollection class to set row height across the grid. You can also specify the height of a particular row by setting Height property of the Row class. Default value of the Height property is -1 which indicates that the row is taking height specified by the DefaultSize property.

    Use the code below to set the default height of a row of the WinForms FlexGrid.

    //Set the default size of all rows
    c1FlexGrid1.Rows.DefaultSize = 50;
    
    //Set the height of a particular row
    c1FlexGrid1.Rows[1].Height = 55;                       
    
    ' Set the default size of all rows
    c1FlexGrid1.Rows.DefaultSize = 50
    
    ' Set the height of a particular row
    c1FlexGrid1.Rows(1).Height = 55
                            
    

    Auto-adjust Row Height

    To adjust the row height according to text length and word wrapping options, FlexGrid provides the AutoSizeRow() and AutoSizeRows() methods. While AutoSizeRow() method automatically adjusts height of the specified row, the AutoSizeRows() method is used for cell ranges.

    Following code shows how you can auto adjust the row height according to the text length in the WinForms FlexGrid.

    //Adjust the height of fourth row automatically
    c1FlexGrid1.AutoSizeRow(4);
        
    //Adjust the height of all rows automatically 
    c1FlexGrid1.AutoSizeRows();
        
    //Adjust the height of cell range automatically
    //c1FlexGrid1.AutoSizeRows(2, 4, 5, 6, 10, C1.Win.C1FlexGrid.AutoSizeFlags.None);
    
        'Adjust the height of fourth row automatically
        c1FlexGrid1.AutoSizeRow(4)
    
        'Adjust the height of all rows automatically 
        c1FlexGrid1.AutoSizeRows()
    
        'Adjust the height of cell range automatically
        'c1FlexGrid1.AutoSizeRows(2, 4, 5, 6, 10, C1.Win.C1FlexGrid.AutoSizeFlags.None)
                            
    

    Set Min/Max Row Height

    FlexGrid allows you to set bounds to the row height by using the MinSize and MaxSize properties of the RowCollection class. This feature is especially useful in scenarios such as when AllowResizing property is set to true or while using the AutoSizeRow() or AutoSizeRows() method.

    Specify the bounds of row height in the WinForms FlexGrid using the code below.  

    //Set the maximum height of row
    c1FlexGrid1.Rows.MaxSize = 50;
        
    //Set the minimum height of row
    c1FlexGrid1.Rows.MinSize = 20;
    
    'Set the maximum height of row
    c1FlexGrid1.Rows.MaxSize = 50
    
    'Set the minimum height of row
     c1FlexGrid1.Rows.MinSize = 20      
    
    See Also

    Documentation