Spread Windows Forms 17
Spread Windows Forms 17.0 Product Documentation / Developer's Guide / Tables / Resizing a Table
In This Topic
    Resizing a Table
    In This Topic

    You can resize the table with the resize indicator in the bottom, right corner of the table or you can use code to do so.

    Resize Table using Resize Indicator

    Select the indicator and drag to the right to add columns or down to add rows.

    Using Code

    You can use the Resize method to add columns or rows to a table. The below example code adds rows and columns to the table.

    C#
    Copy Code
    FarPoint.Win.Spread.TableStyle tstyle = fpSpread1.CreateTableStyle("Style1", FarPoint.Win.Spread.TableStyle.TableStyleLight2);
                
    fpSpread1.Sheets[0].Cells[1, 1].Text = "Last Name";
    fpSpread1.Sheets[0].Cells[1, 2].Text = "Value";
    fpSpread1.Sheets[0].Cells[2, 1].Text = "Smith";
    fpSpread1.Sheets[0].Cells[2, 2].Value = 50;
    fpSpread1.Sheets[0].Cells[3, 1].Text = "Vil";
    fpSpread1.Sheets[0].Cells[3, 2].Value = 10;
    fpSpread1.Sheets[0].Cells[4, 1].Text = "Press";
    fpSpread1.Sheets[0].Cells[4, 2].Value = 78;
    fpSpread1.TableStyleCollection.Add(tstyle);
                
    FarPoint.Win.Spread.TableView table = fpSpread1.Sheets[0].AddTable("table", 1, 1, 5, 2, "Style1");
    
    table.Resize(6, 2);
    
    Visual Basic
    Copy Code
    Dim tstyle As FarPoint.Win.Spread.TableStyle
    tstyle = FpSpread1.CreateTableStyle("Style1", FarPoint.Win.Spread.TableStyle.TableStyleLight2)
    FpSpread1.Sheets(0).Cells(1, 1).Text = "Last Name"
    FpSpread1.Sheets(0).Cells(1, 2).Text = "Value"
    FpSpread1.Sheets(0).Cells(2, 1).Text = "Smith"
    FpSpread1.Sheets(0).Cells(2, 2).Value = 50
    FpSpread1.Sheets(0).Cells(3, 1).Text = "Vil"
    FpSpread1.Sheets(0).Cells(3, 2).Value = 10
    FpSpread1.Sheets(0).Cells(4, 1).Text = "Press"
    FpSpread1.Sheets(0).Cells(4, 2).Value = 78
    FpSpread1.TableStyleCollection.Add(tstyle)
    
    Dim table As FarPoint.Win.Spread.TableView = FpSpread1.Sheets(0).AddTable("table", 1, 1, 5, 2, "Style1")
    
    table.Resize(6, 2)
    

    Automatically Extend Table Rows or Columns

    You can expand the rows or columns of a table automatically using the AutoExpandTable property.

    A new row or column is added after editing an empty cell located below the row or right of the column.

    The AutoExpandTable property will not expand table rows if the table has a Total row, that is, consists a formula cell in the last row.

    C#
    Copy Code
    fpSpread1.Features.AutoExpandTable = true;
    
    Visual Basic
    Copy Code
    FpSpread1.Features.AutoExpandTable = True
    
    See Also