你总是很粗心![em06] Private Sub Form_Load() With ListView1 .View = lvwReport .GridLines = True .Checkboxes = False .FullRowSelect = True '增加list1 列标头 .ColumnHeaders.Add , , "编号", 1000 .ColumnHeaders.Add , , "购机日期", 1200 .ColumnHeaders.Add , , "联系人", 1200 .ColumnHeaders.Add , , "拼音码", 1200 .ColumnHeaders.Add , , "用户电话", 1500 .ColumnHeaders.Add , , "用户手机", 1500 '列标头关联图标 .ColumnHeaderIcons = ImageList1 .ColumnHeaders(1).Icon = 1 '记录行关联图标
' .Icons = ImageList1
.SmallIcons = ImageList1
' .ListItems(1).Icon = 1
End With Call 读取数据 End Sub Sub 读取数据() '读取数据到ListView Dim CNN As New ADODB.Connection Dim RST As New ADODB.Recordset Dim SQL As String, AddList As ListItem CNN = "Provider=Microsoft.Jet.OLEDB.4.0;" CNN = CNN & "Data Source=" & App.Path & "\data.mdb;" CNN = CNN & "Jet OLEDB:Database Password=" & "cjw79512" CNN.Open SQL = "select * From yhda Order By 用户ID desc" RST.Open SQL, CNN, adOpenKeyset, adLockOptimistic Do While Not RST.EOF Set AddList = ListView1.ListItems.Add(, , RST.Fields("用户ID"), , 1) '将各项数据加入list列表 AddList.SubItems(1) = RST.Fields("购机日期") AddList.SubItems(2) = RST.Fields("联系人") AddList.SubItems(3) = RST.Fields("拼音码") AddList.SubItems(4) = RST.Fields("用户电话") AddList.SubItems(5) = RST.Fields("用户手机") RST.MoveNext Loop RST.Close: Set RST = Nothing CNN.Close: Set CNN = Nothing End Sub |