发现当数据记录的条数超过15000条时,用listview 控件显示后,单击listview中的后面部分数据记录时会自动选中第一条记录。也就是说数据集后面约1/3不能被选中!!真奇怪!有人碰到这种问题么?

解决方案 »

  1.   

    程序如下,应该没有错啊,但是还是出现以上问题:Private Sub Form_Load()
       ' Add ColumnHeaders. The width of the columns is
       ' the width of the control divided by the number of
       ' ColumnHeader objects.
       ListView1.ColumnHeaders.Add
       ListView1.ColumnHeaders.Add , , "Author", ListView1.Width / 3, lvwColumnCenter
       ListView1.ColumnHeaders.Add , , "Author ID", ListView1.Width / 3, lvwColumnCenter
       ListView1.ColumnHeaders.Add , , "Birthdate", ListView1.Width / 3, lvwColumnCenter
       
       ' Set View property to Report.
       'ListView1.View = lvwReport   ' Declare object variables for the
       ' Data Access objects.
       Dim myDb As Database
       'myRs As Recordset
       ' Set the Database to the BIBLIO.MDB database.
       ' IMPORTANT: the Biblio.mdb must be on your
       ' machine, and you must set the correct path to
       ' the file in the OpenDatabase function below.
       Set myDb = DBEngine.Workspaces(0).OpenDatabase("d:\test\db2.MDB")
       ' Set the recordset to the "Authors" table.
       'MsgBox (TypeName(myDb.OpenRecordset("Authors", dbOpenDynaset)))
       Set myRs = myDb.OpenRecordset("Authors", dbOpenDynaset)
       
       ' Declare a variable to add ListItem objects.
       Dim itmX As ListItem   ' While the record is not the last record,
       ' add a ListItem object. Use the author field for
       ' the ListItem object's text. Use the AuthorID
       ' field for the ListItem object's SubItem(1).
       ' Use the "Year of Birth" field for the ListItem
       ' object's SubItem(2).
       
       While Not myRs.EOF
          Set itmX = ListView1.ListItems.Add
          If Not IsNull(CStr(myRs!Author)) Then
           itmX.SubItems(1) = CStr(myRs!Author)
          End If
          
          ' Author.
          
          ' If the AuthorID field is not null, then set
          ' SubItem 1 to it.
          If Not IsNull(myRs!Au_id) Then
             itmX.SubItems(2) = CStr(myRs!Au_id)
          End If      ' If the birth field is not Null, set
          ' SubItem 2 to it.
          If Not IsNull(myRs![Year Born]) Then
             itmX.SubItems(3) = myRs![Year Born]
          End If
          myRs.MoveNext   ' Move to next record.
       Wend
     
      
       Set myDb = Nothing
       Set myRs = Nothing
       
    End SubPrivate Sub ListView1_ItemCheck(ByVal Item As MSComctlLib.ListItem)
    Dim i As Long    For i = 1 To ListView1.ListItems.Count
            If ListView1.ListItems(i).Checked = True Then
            ListView1.ListItems(i).Checked = False
            End If
            If i = Item.Index Then
                Item.Checked = True
                Item.EnsureVisible
                Set ListView1.SelectedItem = Item
            End If
        Next i
    End SubPrivate Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
    ListView1_ItemCheck Item
    End Sub