- 日時: 2009/12/27 15:30
- 名前: 花ちゃん
- ***********************************************************************************
* カテゴリー:[リストビュー][][] * * キーワード:表示速度,処理時間,高速化,,, * ***********************************************************************************
必ず、元の Q & A をご覧下さい。 --- by 花ちゃん ---
----------------------------------------------------------------------------------- No.2898 Re:ListViewの表示を早くしたい 投稿者:ゆう(U) [2001/10/09(火)16:15分] -----------------------------------------------------------------------------------
VB6.0での最適化比較のサンプルを載せますので、参考にしてみて下さい。
サンプル) Private Sub Form_Load() With ListView1 .View = lvwReport .ColumnHeaders.Clear .ColumnHeaders.Add , , "A" .ColumnHeaders.Add , , "B" .ColumnHeaders.Add , , "C" .ColumnHeaders.Add , , "D" .ColumnHeaders.Add , , "E" End With End Sub Private Sub Command1_Click() Dim i As Long Dim myListItem As ListItem Dim sngTimer As Single
ListView1.ListItems.Clear sngTimer = Timer ListView1.Visible = False For i = 0 To 49999 Set myListItem = ListView1.ListItems.Add(, , CStr(i)) myListItem.SubItems(1) = "B" & CStr(i) myListItem.SubItems(2) = "C" & CStr(i) myListItem.SubItems(3) = "D" & CStr(i) myListItem.SubItems(4) = "E" & CStr(i) Next ListView1.Visible = True Debug.Print Format$(Timer - sngTimer, "#,0.00") End Sub Private Sub Command2_Click() Dim i As Long Dim sngTimer As Single
ListView1.ListItems.Clear sngTimer = Timer With ListView1 .Visible = False With .ListItems For i = 0 To 49999 With .Add(, , CStr(i)) ' .SubItems(1) = "B" & CStr(i) ' .SubItems(2) = "C" & CStr(i) ' .SubItems(3) = "D" & CStr(i) ' .SubItems(4) = "E" & CStr(i) With .ListSubItems '上記SubItemsより高速 .Add , , "B" & CStr(i) .Add , , "C" & CStr(i) .Add , , "D" & CStr(i) .Add , , "E" & CStr(i) End With End With Next End With .Visible = True End With Debug.Print Format$(Timer - sngTimer, "#,0.00") End Sub ※件数が多すぎる場合は減らしてテストしてみてください
|