Programmatically prevent only column 0 and right-most column from being dragged?

Posted by: jhoover on 8 September 2017, 12:29 pm EST

  • Posted 8 September 2017, 12:29 pm EST

    I'd like to programatically prevent users from re-ordering the first and last columns. Specifically:



    • First column may not be moved

    • Last column may not be moved

    • No column may be moved to the left of the first column

    • No column may be moved to the right of the last column

    Any ideas?


    Thanks,


    Jeff

  • Replied 8 September 2017, 12:29 pm EST

    Jeff -

    You can cancel the move if a user is trying to move either the first or last column...

    Private Sub FpSpread1_ColumnDragMove(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.DragMoveEventArgs) Handles FpSpread1.ColumnDragMove
    If e.Index = 0 Or e.Index = 4 Then
    e.Cancel = True
    End If
    End Sub

    If they are trying to move to the first or last index just move the columns back...

    Private Sub FpSpread1_ColumnDragMoveCompleted(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.DragMoveCompletedEventArgs) Handles FpSpread1.ColumnDragMoveCompleted
    If e.ToIndex = 0 Then
    FpSpread1.ActiveSheet.MoveColumn(e.ToIndex, e.FromIndex, True)
    End If

    If e.ToIndex = 4 Then
    FpSpread1.ActiveSheet.MoveColumn(e.ToIndex, e.FromIndex, True)
    End If

    End Sub
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels