ReoGrid Forum

Fast and powerful .NET Spreadsheet Component

You are not logged in.

Announcement

This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.

https://github.com/unvell/ReoGrid/issues

#1 2016-04-12 01:22:22

asparatu
Member
Registered: 2014-08-20
Posts: 196

BeforePaste event Question

Hello Jing,
   I see something that is weird.. I have before paste event that check to see if the numbers being copy are numeric and if not make the cell empty. When i do book.DoAction(New SetRangeDataAction(range, data)), it fires the cellchangeddata event, which is right, after that it does the BeforeSelectionRangeChange Event, then back to the BeforePaste event, right after that it does the cellchangedData event again, which is the weird thing about it, when it already did it.  I dont think it should be firing the cellchangeddata event twice.

is there reason why the CellChangedData event is firing second time after leaving the BeforePaste Event?

Shane

BeforePaste code

Private Sub BeforPasteIsNumeric(book As ReoGridControl, sheet As Worksheet, e As BeforeRangeOperationEventArgs)
        Dim data(,) As Object
        Dim range As RangePosition

        'WorkSheet Settings
        With sheet
            'Sets the clipboard data to array
            data = RGUtility.ParseTabbedString(Clipboard.GetText)
            'sets the new range to be pasted into
            range = New RangePosition(.SelectionRange.Row, .SelectionRange.Col, data.GetLength(0), data.GetLength(1))
            'Checks to see if the paste is numeric or alpha
            For i As Integer = 0 To data.GetLength(0) - 1
                For j As Integer = 0 To data.GetLength(1) - 1
                    If Not IsNumeric(data(i, j)) Then
                        e.IsCancelled = True
                        data(i, j) = String.Empty
                    End If
                Next
            Next
        End With

        'WorkBook Settings
        With book
            .DoAction(New SetRangeDataAction(range, data))
        End With
    End Sub

BeforeSelectionChange Event code

 Private Sub BeforeSelectionChange(sender As Object, e As BeforeSelectionChangeEventArgs, validRange As RangePosition)
        ' Disable to select any cells outside validRanges
        e.IsCancelled = Not validRange.Contains(e.SelectionStart) OrElse Not validRange.Contains(e.SelectionEnd)
    End Sub

cellChangedData Event

    Private Sub rgBallparkReadingsSheet_CellDataChanged(sender As Object, e As CellEventArgs) Handles rgBallparkReadingsSheet.CellDataChanged
        'Check to see if there is new project being loaded.
        If m_blnNewRecordFlag Then Exit Sub
        'Checks to see if the column is 5 
        If e.Cell.Column = 5 Then Exit Sub

        'gets the target from distance
        Call SetBallparkReadingDistanceFromTarget(sender, e)

        'Checks to see test can be done
        Call SetBallparkCalculates()
    End Sub

Offline

Board footer

Powered by FluxBB