Spread Windows Forms 11.0 Product Documentation
Moving a Sheet
Spread Windows Forms 11.0 Product Documentation > Developer's Guide > Understanding the Spreadsheet Objects > Working with Sheets > Moving a Sheet

If you have multiple sheets, you can move a sheet. If you move the first sheet location to the last sheet location, then the other sheets are moved to the left. If you move the sheet location to the location of the sheet next to it, then this effectively swaps the sheets.

Specify the from and to location using the sheet index. The sheet index is zero‑based.

Moving a sheet does not change the sheet name.

The AllowSheetMove property of the FpSpread class can be set to true to allow the user to move the sheets using the sheet tabs. You can also hide a sheet. For more information, refer to Showing or Hiding a Sheet.

You can prevent a user from moving a specific sheet with the SheetDragMoving and SheetDragMoved events. Select a sheet tab on the tab strip, drag the sheet tab to another tab, then release the mouse to move the sheet from the old index to the new index. The SheetDragMoving event occurs when the user starts dragging the sheet tab name. The SheetDragMoved event occurs right after the user moves the sheet. You can prevent specific sheets from being moved by setting the Cancel property to true in the SheetDragMoving event.

To move an existing sheet, complete the following instructions.

Using a Shortcut

Call the Sheets Move method (to move the sheet from one location to another).

Example

This example code moves the second sheet to the location of the third sheet.

C#
Copy Code
// Move sheet 2 to the location of sheet 3.
fpSpread1.Sheets.Count = 5;
fpSpread1.Sheets.Move(2, 3);
VB
Copy Code
' Move sheet 2 to the location of sheet 3.
fpSpread1.Sheets.Count = 5
fpSpread1.Sheets.Move(2, 3)
See Also