C1FlexGridClassic take double time to populate the Grid compare to VSFlexGrid

Posted by: skm.mas on 27 April 2020, 11:37 pm EST

    • Post Options:
    • Link

    Posted 27 April 2020, 11:37 pm EST

    C1FlexGridClassic take double time to populate the Grid compare to VSFlexGrid. using .set_textmatrix method

    
      If DSIR.Tables("pdt").Rows.Count > 0 Then
        For i = 0 To DSIR.Tables("pdt").Rows.Count - 1
          With fgItems
            .Rows = .Rows + 1
            .set_TextMatrix(.Rows - 1, 1, DSIR.Tables("pdt").Rows(i).Item("Code"))
            .set_TextMatrix(.Rows - 1, 2, IIf(IsDBNull(pdt.Tables("POTC").Rows(i).Item("Name")), "", DSIR.Tables("pdt").Rows(i).Item("Name")))
          End With
        Next
      End If
    
    
  • Posted 28 April 2020, 3:06 am EST

    Hi,

    before starting filling the grid, call “fgItems.BeginUpate()”, and afterwards “fgItems.EndUpdate()”. This should bring a major performance improvement.

    Best regards

    Wolfgang

  • Posted 28 April 2020, 5:28 am EST

    Hello,

    Like Wolfgang suggested, please enclose the code for populating grid within BeginUpdate and EnUpdate methods.

    For additional tips related to using FlexGrid, you may refer the following page:

    https://www.grapecity.com/componentone/docs/win/online-flexgrid/flexgridforwinformsttoptips.html

    Thanks,

    Ruchir

  • Posted 28 April 2020, 12:12 pm EST

    Using BeginUpdate() and EndUpdate() method speed increased but not as expected

  • Posted 28 April 2020, 11:27 pm EST

    Hi,

    1. How are you populating data in FlexGrid Classic?
    2. Please share information about the number of rows, columns, type of data and the time taken for the grid to get populated. We would like to check this at our end.

    Thanks,

  • Posted 5 June 2020, 8:53 am EST

    1. Designing the Grid using code

    ‘’—Design the grid

    Private Sub GridInfo()

    With fgItem

    .AllowUserResizing = C1.Win.C1FlexGrid.Classic.AllowUserResizeSettings.flexResizeColumns

    .ExplorerBar = C1.Win.C1FlexGrid.Classic.ExplorerBarSettings.flexExSortShow

    .SelectionMode = C1.Win.C1FlexGrid.Classic.SelModeSettings.flexSelectionByRow

    .TabBehavior = C1.Win.C1FlexGrid.Classic.TabBehaviorSettings.flexTabCells

    .FontBold = False

    .FixedRows = 1

    .FixedCols = 0

    .Rows = 1

    .Cols = 10

    .Width = 668

    .Height = 348

    .set_ColWidth(0, 0)

    .set_TextMatrix(0, 0, “Sn.”)

    .set_ColHidden(0, False)

    .set_ColWidth(1, 70)

    .set_TextMatrix(0, 1, “Item Code”)

    .set_ColWidth(2, 70)

    .set_TextMatrix(0, 2, “Item Code Gen”)

    .set_ColHidden(2, True)

    .set_ColWidth(3, 250)

    .set_TextMatrix(0, 3, “Item Name”)

    .set_ColWidth(4, 80)

    .set_TextMatrix(0, 4, “OEM PartNo”)

    .set_ColWidth(5, 70)

    .set_TextMatrix(0, 5, “Old Code”)

    .set_ColWidth(6, 70)

    .set_TextMatrix(0, 6, “”)

    .set_ColHidden(6, True)

    .set_ColWidth(7, 100)

    .set_TextMatrix(0, 7, “Unit of Packaging”)

    .set_ColHidden(7, True)

    .set_ColWidth(8, 70)

    .set_TextMatrix(0, 8, “Curr. Bal”)

    .set_ColWidth(9, 80)

    .set_TextMatrix(0, 9, “BarCode No.”)

    End With

    End

    1. Populate the Gid

      ‘’—Populate the Grid

      Private Sub FillGrid()

      Dim strQuery As String

      Dim i As Integer

      Try

      f_DSGrid.Clear()

      strQuery = “SELECT ItemID,ItemCode,ItemCodeGen,Description, OEMPartNo, OldCode, UnitPackaging, CurrentBalance, BarCodeNumber FROM ItemMaster ORDER BY Description”

      f_DAGrid = New SqlDataAdapter(strQuery, Connect.gl_Connect)

      f_DAGrid.Fill(f_DSGrid, “FillGrid”)

      fgItem.BeginUpdate()

      If f_DSGrid.Tables(“FillGrid”).Rows.Count <> 0 Then

      For i = 1 To f_DSGrid.Tables(“FillGrid”).Rows.Count

      fgItem.Rows = fgItem.Rows + 1

      fgItem.set_TextMatrix(i, 0, fgItem.Rows - 1)

      fgItem.set_TextMatrix(i, 1, IIf(IsDBNull(f_DSGrid.Tables(“FillGrid”).Rows(i - 1).Item(“ItemCode”)), “”, f_DSGrid.Tables(“FillGrid”).Rows(i - 1).Item(“ItemCode”)))

      fgItem.set_TextMatrix(i, 2, IIf(IsDBNull(f_DSGrid.Tables(“FillGrid”).Rows(i - 1).Item(“ItemCodeGen”)), “”, f_DSGrid.Tables(“FillGrid”).Rows(i - 1).Item(“ItemCodeGen”)))

      fgItem.set_TextMatrix(i, 3, IIf(IsDBNull(f_DSGrid.Tables(“FillGrid”).Rows(i - 1).Item(“Description”)), “”, f_DSGrid.Tables(“FillGrid”).Rows(i - 1).Item(“Description”)))

      fgItem.set_TextMatrix(i, 4, IIf(IsDBNull(f_DSGrid.Tables(“FillGrid”).Rows(i - 1).Item(“OEMPartNo”)), “”, f_DSGrid.Tables(“FillGrid”).Rows(i - 1).Item(“OEMPartNo”)))

      fgItem.set_TextMatrix(i, 5, IIf(IsDBNull(f_DSGrid.Tables(“FillGrid”).Rows(i - 1).Item(“OldCode”)), “-”, f_DSGrid.Tables(“FillGrid”).Rows(i - 1).Item(“OldCode”)))

      fgItem.set_TextMatrix(i, 7, IIf(IsDBNull(f_DSGrid.Tables(“FillGrid”).Rows(i - 1).Item(“UnitPackaging”)), “”, f_DSGrid.Tables(“FillGrid”).Rows(i - 1).Item(“UnitPackaging”)))

      fgItem.set_TextMatrix(i, 8, IIf(IsDBNull(f_DSGrid.Tables(“FillGrid”).Rows(i - 1).Item(“CurrentBalance”)), “”, f_DSGrid.Tables(“FillGrid”).Rows(i - 1).Item(“CurrentBalance”)))

      fgItem.set_TextMatrix(i, 9, IIf(IsDBNull(f_DSGrid.Tables(“FillGrid”).Rows(i - 1).Item(“BarCodeNumber”)), “”, f_DSGrid.Tables(“FillGrid”).Rows(i - 1).Item(“BarCodeNumber”)))

      Next

      fgItem.EndUpdate()

      fgItem.Row = 1

      fgItem.Select()

      End If

      f_DSGrid.Clear()

      f_DSGrid.Dispose()

      f_DAGrid.Dispose()

      Catch ex As Exception

      MsgBox(ex.Message, MsgBoxStyle.Information, Connect.sayDeta)

      End Try

      End Sub

    2. Searching in Grid… This is very slow now

      ‘’---------Search in Grid — It is taking too much time

      Private Sub txtsearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtsearch.TextChanged

      Dim intLoop, intLoop1, intLength, intRowFound As Integer

      intLength = Len(txtsearch.Text)

      If fgItem.Rows > 1 Then

      For intLoop1 = 0 To fgItem.Cols - 1

      For intLoop = 1 To fgItem.Rows - 1

      If LCase(txtsearch.Text) = LCase(Mid(fgItem.get_TextMatrix(intLoop, intLoop1), 1, intLength)) Then

      f_intRowFound = intLoop

      fgItem.Row = intRowFound

      fgItem.TopRow = intRowFound

      Exit Sub

      Else

      fgItem.Row = intRowFound

      fgItem.TopRow = intRowFound

      End If

      Next

      Next

      End If

      End Sub

  • Posted 5 June 2020, 9:44 am EST

    Hi,

    could you create a full sample application? Without a real sample, it is hard to say what might be the reason. It is hard as you cannot post the database, but you might populate the DataSet with random data.

    The code looks OK. How many rows does the grid contain?

    When filling the grid, a possible performance issue might be that you make many calls to “f_DSGrid.Tables(“FillGrid”).Rows(i - 1)”. Better declare a table row variable and assign the value of this expression to it, then use this variable to pick the col value: “myRow.Item(“ItemCode”)”.

    Best regards

    Wolfgang

  • Posted 6 June 2020, 8:46 am EST

    Attaching sample project with data. Searching is very slow

  • Posted 6 June 2020, 8:54 am EST

    Hi,

    there is no attachment. Sometimes, this forum has problems with file upload. Retry it again, or do it with a different browser.

    Best regards

    Wolfgang

  • Posted 6 June 2020, 1:20 pm EST

    Attach sample project in vb.net

    C1FlexGridClassic.zip

  • Posted 7 June 2020, 7:13 am EST

    Hi,

    the performance problems are caused by setting “Row” and “TopRow” each time a row does NOT match the text filter.

    After removing those two rows (“else” block), everything is fast:

    
      Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
        Dim intLoop, intLoop1, intLength, intRowFound As Integer
        intLength = Len(TextBox1.Text)
        If C1FlexGridClassic1.Rows > 1 Then
          For intLoop1 = 0 To C1FlexGridClassic1.Cols - 1
            For intLoop = 1 To C1FlexGridClassic1.Rows - 1
              If LCase(TextBox1.Text) = LCase(Mid(C1FlexGridClassic1.get_TextMatrix(intLoop, intLoop1), 1, intLength)) Then
                intRowFound = intLoop
                C1FlexGridClassic1.Row = intRowFound
                C1FlexGridClassic1.TopRow = intRowFound
                Exit Sub
              Else
                'C1FlexGridClassic1.Row = intRowFound
                'C1FlexGridClassic1.TopRow = intRowFound
              End If
            Next
          Next
        End If
      End Sub
    
    

    Best regards

    Wolfgang

  • Posted 8 June 2020, 3:32 am EST

    Thanks. It’s works

    In this method search by the first letter starting in col/row not the first letter of any word in col/row

    I also used for search in col/row by any word first letter

    
      Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
        Dim intLoop, intLoop1, intLength, intRowFound As Integer
        Dim SearchInRows As String = Nothing
        intLength = Len(TextBox1.Text)
        If C1FlexGridClassic1.Rows > 1 Then
          For intLoop1 = 0 To C1FlexGridClassic1.Cols - 1
            For intLoop = 1 To C1FlexGridClassic1.Rows - 1
              SearchInRows = LCase(C1FlexGridClassic1.get_TextMatrix(intLoop, intLoop1))
              If SearchInRows Is Nothing Then
              Else
                If SearchInRows.Contains(LCase(TextBox1.Text)) Then
                  intRowFound = intLoop
                  C1FlexGridClassic1.Row = intRowFound
                  C1FlexGridClassic1.TopRow = intRowFound
                  intRowFound = 0
                  Exit Sub
                End If
              End If
            Next
          Next
        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