0

这个问题很简单,你们中的许多人已经知道Listview即使它被隐藏也会慢得多。有一些建议,例如:

  1. 加载部分数据,然后在滚动时加载,但默认情况下没有滚动事件
  2. 加载部分数据,然后提供按钮以加载更多(比如 50 条)记录
  3. 加载部分数据,显示屏幕,然后使用计时器加载剩余数据

还有什么建议?

如何LockWindowUpdate工作?是否等于ListView.Visible = FalseListviews是否可以使用此 API 锁定两个或更多?

编辑

HyperList看起来很棒,但它的使用很复杂,有人可以简化它或解释调用者端发生的事情,即如何填充数组。

4

2 回答 2

1

这里最明显的解决方案是您提到的所有解决方案之间的交叉;基本上是分页。加载一个设定的数字,然后允许用户使用控件上方或下方的编号页面序列来向后和向前翻页ListView

要进一步加快速度,请不要使用 active RecordSet; 相反,将数据加载到数组中,然后直接将信息放入控件中。如果要编辑信息而不是在 ListView 控件中进行编辑,请使用替代表单。

或者,您可以创建自己的ListView等价物并使用自己的格式将对象直接写入表单。

我认为,如果您必须使用类似的东西,LockWindowUpdate那么您就走错了路。您应该能够使用控件的适当属性来防止用户干扰。

- 编辑 -

这个想法是将数据读入内存中的数组,然后循环遍历它并ListView以与此类似的方式填充您的数据:

Private Function TestInsertListView() As Long
    Dim i As Long
    Dim j As Long
    Dim lT As Long
    Dim itmX As ListItem
    lT = timeGetTime

    ' Add first row
    With lvwTest
        i = 1
        Set itmX = .ListItems.Add(, , "Row" & i & ";Col 1")
        For j = 2 To mcCOLS
           itmX.SubItems(j - 1) = "Row" & i & ";Col" & j - 1
        Next

        For i = 2 To m_iRows
           Set itmX = .ListItems.Add(i, , "Row" & i & ";Col 1")
           For j = 2 To mcCOLS
              itmX.SubItems(j - 1) = "Row" & i & ";Col" & j - 1
           Next
        Next
     End With
     TestInsertListView = timeGetTime - lT

End Function

(我在这里找到了上面的例子。)

显然,您需要修改上述内容以包括数据的读取,但这应该非常简单。 此链接提供了 ADOGetRows方法的演示,该方法允许您读取数据。

于 2013-04-25T13:32:34.833 回答
1

For suggestion #1 - You could either superempose your only vertical scroll bar on top of the list view control, or subclass the ListView control.

Alternatively, you could use the ItemClick() event (clicking items near the bottom of the list) to determine whether more lines need to be loaded.

Don't use LockWindowUpdate - that is meant to be used for processes which need to draw into windows belonging to other processes when do drag-drop. Google OldNewThing LockWindowUpdate for articles explaining how it works and why using this is a bad idea. It isn't equal to ListView.Visible = False. You can only use one window at a time with this API call.

Use the following SendMessage calls to disable and enable updating.

Private Declare Function SendMessage Lib "User32.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Const WM_SETREDRAW  As Long = &HB
Private Const SR_ON         As Long = 1
Private Const SR_OFF        As Long = 0

SendMessage ListView.hWnd, WM_SETREDRAW, SR_OFF, 0&
SendMessage ListView.hWnd, WM_SETREDRAW, SR_ON, 0&
于 2013-04-25T13:53:09.780 回答