If a workbook contains more than one sheet, the tab strip displays the sheet name tabs with the tab for the active sheet highlighted. In this scenario, by using the previous and next tab strip buttons present in the bottom left corner of the workbook, you can navigate to the previous or next sheet of the active sheet.
If you want to jump to the first or last sheets without any manual scrolling, follow the steps below.
C# |
Copy Code
|
---|---|
fpSpread1.Width = 800; fpSpread1.Sheets.Count = 6; fpSpread1.TabStripRatio = 0.7; |
Visual Basic |
Copy Code
|
---|---|
FpSpread1.Width = 800 FpSpread1.Sheets.Count = 6 FpSpread1.TabStripRatio = 0.7 |
Spread also allows you to open the Activate dialog using ActivateSheet method of the BuiltInDialogs class as shown below.
C# |
Copy Code
|
---|---|
// Open Activate dialog by code
fpSpread1.Sheets.Count = 3;
FarPoint.Win.Spread.Dialogs.BuiltInDialogs.ActivateSheet(fpSpread1);
|
Visual Basic |
Copy Code
|
---|---|
' Open Activate dialog by code
FpSpread1.Sheets.Count = 3
FarPoint.Win.Spread.Dialogs.BuiltInDialogs.ActivateSheet(FpSpread1)
|
However, when not in use, you can hide the Activate dialog and tooltip and disable the tab strip buttons.
C# |
Copy Code
|
---|---|
fpSpread1.GetActionMap().Parent.Remove(SpreadActions.ShowActivateSheetDialog); |
Visual Basic |
Copy Code
|
---|---|
FpSpread1.GetActionMap().Parent.Remove(SpreadActions.ShowActivateSheetDialog) |
C# |
Copy Code
|
---|---|
fpSpread1.SetToolTip(SpreadToolTip.TabStripNextSheet, ""); fpSpread1.SetToolTip(SpreadToolTip.TabStripPreviousSheet, ""); |
Visual Basic |
Copy Code
|
---|---|
FpSpread1.SetToolTip(SpreadToolTip.TabStripNextSheet, "") FpSpread1.SetToolTip(SpreadToolTip.TabStripPreviousSheet, "") |
C# |
Copy Code
|
---|---|
private void FpSpread1_MouseDown(object sender, MouseEventArgs e) { if ((Control.ModifierKeys & Keys.Control) != 0) { FpSpread spread = (FpSpread)sender; HitTestInformation ht = spread.HitTest(e.X, e.Y); if (ht.Type == HitTestType.TabStrip) { switch (ht.TabStripInfo.Button) { case TabStripButton.Next: case TabStripButton.Previous: spread.Capture = false; break; } } } } |
Visual Basic |
Copy Code
|
---|---|
Private Sub FpSpread1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) If (Control.ModifierKeys And Keys.Control) <> 0 Then Dim spread As FpSpread = CType(sender, FpSpread) Dim ht As HitTestInformation = spread.HitTest(e.X, e.Y) If ht.Type = HitTestType.TabStrip Then Select Case ht.TabStripInfo.Button Case TabStripButton.[Next], TabStripButton.Previous spread.Capture = False End Select End If End If End Sub |
You can change the default behavior of the TabStrip buttons to personalize their functionality. When you click the previous or next tab strip buttons in the bottom left corner of the worksheet, you can navigate to the sheet before or after the active one. However, using the TabStrip.ButtonClick event, you may switch between sheet tabs by making the previous or next sheets as active. For example, if you are on 'Sheet1' and click the next tab strip button, then the 'Sheet2' becomes the active sheet.
The following example code depicts the use of TabStrip.ButtonClick event.
C# |
Copy Code
|
---|---|
fpSpread1.Sheets.Count = 8; fpSpread1.TabStrip.ButtonClick += TabStrip_ButtonClick; private void TabStrip_ButtonClick(object sender, TabStripButtonClickEventArgs e) { e.Handled = true; if (e.Button == TabStripButton.Next) { fpSpread1.ActiveSheetIndex += 1; } else if (e.Button == TabStripButton.Previous) { fpSpread1.ActiveSheetIndex -= 1; } } |
Visual Basic |
Copy Code
|
---|---|
FpSpread1.Sheets.Count = 8 FpSpread1.TabStrip.ButtonClick += TabStrip_ButtonClick Private Sub TabStrip_ButtonClick(sender As Object, e As TabStripButtonClickEventArgs) e.Handled = true If e.Button Is TabStripButton.Next Then FpSpread1.ActiveSheetIndex += 1 ElseIf e.Button Is TabStripButton.Previous Then FpSpread1.ActiveSheetIndex -= 1 End If End Sub |