We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Copy Paste and Speed

Im attaching a sample i was hoping you could help me figure out. run the sample and type 99.99 in cell 1,1 and then move off and then back on the cell and do a ctrl-c. then click column header "A" and then drag ur mouse all the way over until all cols are selected up to the last one "AF". Now do a ctrl-v and it seems to only take me about 2 seconds tops. Now close the app and bring up excel. Type in 99.99 in a cell and copy that cell in excel. Run my app again and this time just select all the cols again as i had you do above. Now do the ctrl-v. Now this takes me about 5 to 8 seconds. Whats the diff between copying from grid to grid versus excel to grid that slow you down that much. Any idea? I will email this file in case it doesnt send.

7 Replies

AD Administrator Syncfusion Team April 27, 2005 08:44 PM UTC

Hi Philip, The sample is not attached. When you run the application in the VS, did you see any exceptions in the output window of Visual Studio? Regards, Thomas >Im attaching a sample i was hoping you could help me figure out. run the sample and type 99.99 in cell 1,1 and then move off and then back on the cell and do a ctrl-c. then click column header "A" and then drag ur mouse all the way over until all cols are selected up to the last one "AF". Now do a ctrl-v and it seems to only take me about 2 seconds tops. Now close the app and bring up excel. Type in 99.99 in a cell and copy that cell in excel. Run my app again and this time just select all the cols again as i had you do above. Now do the ctrl-v. Now this takes me about 5 to 8 seconds. Whats the diff between copying from grid to grid versus excel to grid that slow you down that much. Any idea? I will email this file in case it doesnt send.


AD Administrator Syncfusion Team April 28, 2005 12:34 PM UTC

The sample wasnt attached to this because the upload feature is still having problems. So i emailed it directly to syncfusion support


AD Administrator Syncfusion Team April 28, 2005 12:41 PM UTC

Ok i checked this and i did email it. You want the email that has this forumn number and the file is called copypastespeed.zip. I had sent another question and sample after this and left the same forum number on the subject. I resent that one this morning.


AD Administrator Syncfusion Team April 28, 2005 01:21 PM UTC

Hi Philip, I''m don''t work at Syncfusion, so I cannot receive the mails. The past day''s I haven''t any problems to upload files. Regards, thomas


AD Administrator Syncfusion Team April 29, 2005 01:43 PM UTC

I figured that. I will see what syncfusion has.


AD Administrator Syncfusion Team April 29, 2005 06:13 PM UTC

Try modifying your ClipboardPaste function as below. You are constanting retrieiving the same value from the clipboard in the loop. As noted earlier in one of your threads, excel puts a newline at the end of its copy of a single cell. Just constantly getting this string with the newline from the clipboard object is slowing things down. (If you type 99.99 in NotePad and copy the exact 5 characters 99.99, you do not see this delay with your original code.)
Private Function ClipboardPaste(ByVal dg As Grid.GridControl) As Boolean

    Try
      Cursor = Cursors.WaitCursor

      Dim intRow, intCol As Integer
      Dim objRow As Grid.GridRangeInfo

      Dim objRange As Grid.GridRangeInfo = dg.Selections.Ranges.ActiveRange
      objRange = objRange.ExpandRange(1, 1, dg.RowCount, dg.ColCount)

      '' Declares an IDataObject to hold the data returned from the clipboard.
      '' Retrieves the data from the clipboard.
      Dim iData As IDataObject = Clipboard.GetDataObject()
      Dim strText() As String

      ''If there is more than one row, return false so that the paste can proceed.
      strText = Split(CType(iData.GetData(DataFormats.Text), String), vbNewLine)
      If strText.GetUpperBound(0) > 1 Then
        Return False
        Exit Function
      End If

      ''If there is more than one column, return
      strText = Split(CType(iData.GetData(DataFormats.Text), String), vbTab)
      If strText.GetUpperBound(0) > 0 Then
        Return False
        Exit Function
      End If

      ''If the paste is a single cell, return false so that the paste can proceed.
      If objRange.Top = objRange.Bottom And objRange.Left = objRange.Right Then
        Return False
            End If

            Dim pasteValue As String = CType(iData.GetData(DataFormats.Text), String)
            pasteValue = pasteValue.Trim()
            Try
                Dim i As Single = Single.Parse(pasteValue)
                Select Case i
                    Case 0.0F To 99.99F
                    Case Else
                        Throw New Exception("")
                End Select
            Catch
                MessageBox.Show("Paste function terminated.  Data doesn''t match cell type or is outside of cell value limits.", _
                  "QUASAR:  Edit Cell Value Warning", MessageBoxButtons.OK, _
                  MessageBoxIcon.Warning)
                Return True ''false
            End Try

            ''Loop through the selected rows and paste the value into each cell.
            For intRow = objRange.Top To objRange.Bottom
                Try
                    Cursor = Cursors.WaitCursor
                    ''Paste into each cell for the row.
                    For intCol = objRange.Left To objRange.Right
                       
                        '' Determines whether the data is in a format you can use.
                        If iData.GetDataPresent(DataFormats.Text) Then
                            ''Put the clipboard value into the cell.
                            If dg(intRow, 0).Text = "  ....  " OrElse _
                              dg(intRow, intCol).Clickable = False Then
                                ''''''Skip Non Issue Read only cells 
                            Else
                                data(intRow, intCol).SetValue(data(intRow, intCol).CellValueProperty, pasteValue)
                            End If
                        End If
                    Next

                Catch ex As System.Exception
                    MessageBox.Show(ex.ToString)
                Finally
                    Cursor = Cursors.Default
                End Try
            Next
            Return True

        Catch ex As System.Exception
      MessageBox.Show(ex.ToString)
    Finally
      Cursor = Cursors.Default
    End Try

  End Function


AD Administrator Syncfusion Team April 29, 2005 07:12 PM UTC

That made a HUGE difference. Takes no time at all now. Thanks Clay

Loader.
Live Chat Icon For mobile
Up arrow icon