listview virtual mode 的问题,求解!!
程序代码:
,想将数据库中的各项导入到listview,由于数据庞大,所以用 virtual mode,但是始终不成功!! Public Class customer Public cnn As New OleDb.OleDbConnection Public cmd As New OleDb.OleDbCommand Public da As New OleDb.OleDbDataAdapter Public dr As OleDb.OleDbDataReader Dim ds As New DataSet Dim dt As New DataTable Dim listitem() As ListViewItem Private firstItem As Integer Dim arr As ArrayList Private Sub customer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ListView1.Items.Clear() ListView1.GridLines = True ListView1.VirtualMode = True ListView1.VirtualListSize = 0 Call CheckImportListView() End Sub Private Sub CheckImportListView() Dim sql As String cnn.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;data Source=" & Application.StartupPath & "\database.mde " sql = "Select ID,name,TEL from [客户]" Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(sql, cnn) da.Fill(ds, "客户") Dim i As Integer = 0 listitem = New ListViewItem(ds.Tables("客户").Rows.Count - 1) {} For Each dRow As DataRow In ds.Tables("客户").Rows For i = 1 To ds.Tables("客户").Columns.Count listitem(i) = New ListViewItem(dRow("ID").ToString) //listitem(i) = New ListViewItem(dRow("name").ToString) i = i + 1 Next Next ListView1.VirtualListSize = ds.Tables("客户").Rows.Count End Sub Private Sub ListView1_RetrieveVirtualItem(ByVal sender As Object, ByVal e As System.Windows.Forms.RetrieveVirtualItemEventArgs) Handles ListView1.RetrieveVirtualItem Dim x As Integer = e.ItemIndex * e.ItemIndex e.Item = New ListViewItem(x.ToString()) End Sub End Class virtualListview中只显示第一列(ID)的数据,如何添加显示第二列(name)、第三列(Tel)数据.