2

2つのvbacceleratorssgridsに入力する必要のあるレコードがそれぞれ約10Kあります。現在、次のコードを使用しています。

With grdList
     .Clear
     If colTasks Is Nothing Then Exit Sub
     .ReDraw = False
     For i = 1 To colTasks.Count
      AddItem colTasks(i)
    Next
  .ReDraw = True
End With

additemサブルーチンは、2つのグリッドで異なり、データが瞳孔化するのに特有です。こんな感じ

    Dim lCol   As Long
    Dim bIsDue As Boolean
    Dim sCat   As String
   sCat = cboCat.Text
   With grdList
       If IsEqual(sCat, oItem.Category) Or IsEqual(sCat, "all") Then
            ' Show/Remove Completed
           If Not IsNullOrEmpty(oItem.DueDate) Then
               sCat = DateDiff("d", oItem.DueDate, DateValue(Now))
               bIsDue = (CLng(sCat) > 0)
               If ShowDueOnly And Not bIsDue Then Exit Function
            End If
        Else
            Exit Function
        End If
      If lRow > .Rows Or lRow = 0 Then
          grdList.AddRow
          lRow = .Rows
        End If
        If Not IsNullOrEmpty(oItem.DueDate) Then
            lCol = .ColumnIndex("DueDate")
          lColor = IIf(bIsDue, vbRed, vbBlack)
          sCat = Format$(oItem.DueDate, "MM/dd/yyyy")
          .CellDetails lRow, lCol, CDate(sCat), DT_LEFT, IconIndex("ARROW"), , lColor
        End If
      lCol = .ColumnIndex("Privacy")
      .CellIcon(lRow, lCol) = IIf(oItem.IsPrivate, IconIndex("LOCK"), -1)
      'completed
      lCol = .ColumnIndex("Complete")
     .CellIcon(lRow, lCol) = IIf(oItem.Completed, IconIndex("CHECK"), -1)         
    End With

グリッドを埋めるのに約20秒かかりますが、とにかくこれを速くすることができますか

4

1 に答える 1

4

sGridのドキュメントには、「行を順番に追加できる場合は、各行を個別に追加するのではなく、SGridに複数の行を事前に割り当てるように選択できます。これにより、パフォーマンスが向上します。これを行うには、Rowsプロパティを設定します。必要な行数に合わせて」

于 2013-02-16T04:29:16.017 に答える