Spread Windows Forms 12.0 Product Documentation
SheetDragMoved Event

FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > FpSpread Class : SheetDragMoved Event
Occurs right after the user finishes drag-moving the sheet to another index.
Public Event SheetDragMoved As SheetDragMovedEventHandler
Dim instance As FpSpread
Dim handler As SheetDragMovedEventHandler
AddHandler instance.SheetDragMoved, handler
public event SheetDragMovedEventHandler SheetDragMoved
Event Data

The event handler receives an argument of type SheetDragMovedEventArgs containing data related to this event. The following SheetDragMovedEventArgs properties provide information specific to this event.

Gets the index of the sheet after moving.  
Gets the index of the sheet before moving.  

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.

This event only occurs when the user uses the mouse to move a sheet.

This example prevents a sheet from being moved to sheet 3.
private void fpSpread1_SheetDragMoving(object sender, FarPoint.Win.Spread.SheetDragMovingEventArgs e)
            if (e.ToSheetIndex == 3)
                e.Cancel = true;
                //or e.Restrict = true;

        private void fpSpread1_SheetDragMoved(object sender, FarPoint.Win.Spread.SheetDragMovedEventArgs e)
            listBox1.Items.Add("previous " + e.OldSheetIndex);
            listBox1.Items.Add("new " + e.NewSheetIndex);

        private void Form1_Load(object sender, EventArgs e)
            fpSpread1.Sheets.Count = 5;
            fpSpread1.AllowSheetMove = true;
Private Sub fpSpread1_SheetDragMoved(sender As Object, e As FarPoint.Win.Spread.SheetDragMovedEventArgs) Handles fpSpread1.SheetDragMoved
        ListBox1.Items.Add("previous " & e.OldSheetIndex)
        ListBox1.Items.Add("new " & e.NewSheetIndex)
    End Sub

    Private Sub fpSpread1_SheetDragMoving(sender As Object, e As FarPoint.Win.Spread.SheetDragMovingEventArgs) Handles fpSpread1.SheetDragMoving
        If e.ToSheetIndex = 3 Then
            e.Cancel = True
           'or e.Restrict = True
        End If
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        fpSpread1.Sheets.Count = 5
        fpSpread1.AllowSheetMove = True
    End Sub
See Also