Spread Windows Forms 7.0 Product Documentation
Adding a Row or Column
Support Options
Spread Windows Forms 7.0 Product Documentation > Developer's Guide > Understanding the Spreadsheet Objects > Working with Rows and Columns > Adding a Row or Column

Glossary Item Box

You can add one or more columns or rows to a sheet, and specify where the column or row is added. You can use the methods in the SheetView class or the methods in the DefaultSheetDataModel class.

Remember, if you set the cell type for the column, then inserting new rows retain the cell type for the entire column. If you set the cell type for individual cells, then inserting rows would require you to set the cell type in the new inserted rows.

For more details refer to the SheetView.AddRows method or SheetView.AddColumns method.

Using a Shortcut

Example

This example code adds two columns before column 6.

C# Copy Code
fpSpread1.Sheets[0].AddColumns(6,2);
VB Copy Code
FpSpread1.Sheets(0).AddColumns(6,2)

Using Code

  1. Use the AddRows or AddColumns method for a SheetView object.
  2. Set the column or row parameter to specify the column or row before which to add the columns or rows.
  3. Set the count parameter to specify the number of columns or rows to add.

Example

This example code adds two columns before column 6.

C# Copy Code
FarPoint.Win.Spread.SheetView Sheet0;
Sheet0 = fpSpread1.Sheets[0];
Sheet0.AddColumns(6,2);
VB Copy Code
Dim Sheet0 As FarPoint.Win.Spread.SheetView
Sheet0 = FpSpread1.Sheets(0)
Sheet0.AddColumns(6, 2)

Using the Spread Designer

  1. Select the sheet tab for the sheet for which you want to add a row or column.
  2. Select a row above which you want to add a row or a column to the left of which you want to add a column.
  3. Right-click on the row or column and choose Insert.

    An additional row or column is added to the sheet.

  4. From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.
© 2002-2014 ComponentOne, a division of GrapeCity. All Rights Reserved.