Spread Windows Forms 10.0 Product Documentation
SheetDragMoving Event
Example 


Occurs when the user drag-move the sheet name tab to move sheet.
Syntax
'Declaration
 
Public Event SheetDragMoving As SheetDragMovingEventHandler
'Usage
 
Dim instance As FpSpread
Dim handler As SheetDragMovingEventHandler
 
AddHandler instance.SheetDragMoving, handler
public event SheetDragMovingEventHandler SheetDragMoving
Event Data

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

PropertyDescription
CancelGets or sets whether to cancel the sheet drag and move action.  
RestrictGets or sets whether to allow the sheet to be moved to the ToSheetIndex location.  
SheetIndexGets the index of the sheet that is being moved.  
ToSheetIndexGets the index of the new position where the sheet is being moved.  
Remarks

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.

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

Example
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
Requirements

Target Platforms: Windows 2000 Professional (SP4), Windows 2000 Server, Windows 2003 Server (SP1), Windows Server 2012 R2, Windows 2008, Windows XP (SP2), Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10

See Also

Reference

FpSpread Class
FpSpread Members

 

 


Copyright © GrapeCity, inc. All rights reserved.