0

Why FocusrowChanged GridView in DevExpress runs slowly in vb.net?

Is there a solution so it doesn't get slow? And the image data there are four thousand. If I run FocusedRowChanged in gridview in the image in pictureedit it immediately appears but the row shift is not direct and becomes slow.

Thanks

Private Sub GridView1_FocusedRowChanged(sender As Object, e As FocusedRowChangedEventArgs) Handles GridView1.FocusedRowChanged
        Dim view As GridView = TryCast(sender, GridView)

        If view.FocusedRowHandle = GridControl.AutoFilterRowHandle Then
            Return
        End If

        Dim SUBFOLDERP As String = view.GetFocusedRowCellValue("SUBFOLDERP")?.ToString
        Dim Filename1 As String = view.GetFocusedRowCellValue("FILENAME1")?.ToString
        Dim Filename2 As String = view.GetFocusedRowCellValue("FILENAME2")?.ToString
        parentpathimage = Directory.GetCurrentDirectory()
        Dim filePath1 = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename1, False)
        Dim filePath2 = DevExpress.Utils.FilesHelper.FindingFileName(parentpathimage & "\" & SUBFOLDERP & "\", Filename2, False)
        If Not String.IsNullOrWhiteSpace(filePath1) Then
            PictureEdit1.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath1)), True, False)
            If Not String.IsNullOrWhiteSpace(filePath2) Then
                PictureEdit2.Image = Image.FromStream(New MemoryStream(File.ReadAllBytes(filePath2)), True, False)
            End If
        End If
    End Sub
roy
  • 693
  • 2
  • 11
  • Which part of the code is slow? – Marko Juvančič Dec 30 '22 at 10:54
  • @MarkoJuvančič , Thank you for your reply. `Dim SUBFOLDERP As String = view.GetFocusedRowCellValue("SUBFOLDERP")?.ToString Dim Filename1 As String = view.GetFocusedRowCellValue("FILENAME1")?.ToString Dim Filename2 As String = view.GetFocusedRowCellValue("FILENAME2")?.ToString` I think here the code is slow – roy Dec 30 '22 at 12:29
  • @MarkoJuvančič , when I use the keyboard up and down on the keyboard it becomes slow if I comment out the code "GridView1_FocusedRowChanged" then with the keyboard up and down it becomes very fast – roy Dec 30 '22 at 12:55
  • @MarkoJuvančič, so the code makes slow is `Private Sub GridView1_FocusedRowChanged(sender As Object, e As FocusedRowChangedEventArgs) Handles GridView1.FocusedRowChanged` – roy Dec 30 '22 at 12:56
  • Use profiler (or use [Stopwatch](https://stackoverflow.com/questions/55686928/using-stopwatch-in-c-sharp)) to determine the slow line(s). – Marko Juvančič Dec 31 '22 at 13:00

0 Answers0