我新建了一个listview控件名为LV1 
现在求源码==>>在lv1中添加4列,分别为:序号,时间,日期,备注 
并且添加两行内容,分别为:1,00:00:00,2008-01-01,(无) 
2,00:00:01,2008-01-01,(无) 哪位大虾帮忙写源码~~~,小弟感谢啊! ! 
总体效果: 
序号 时间 日期 备注 
1 00:00:00 2008-01-01 (无) 
2 00:00:01 2008-01-01 (无) 

解决方案 »

  1.   

    Private Sub cmdOK_Click()
        Dim snp1 As New ADODB.Recordset
        If ListPxdw.ListIndex >= 0 Then
            Screen.MousePointer = 11
            '项目
            sqlstr = "SELECT id AS 序号, xm AS  姓名 , sfzh AS 身份证号 ,dw AS 单位, zz AS 住址 ,bmrq AS 入学日期, ksrq as 考试日期,cylb as 从业类别 , zkzh as 准考证号,jx_cypxcj.rq as 考试日期,jx_cypxcj.ll as 理论,jx_cypxcj.aq as 安全检查,jx_cypxcj.cz as 操作技能,jx_cypxcj.bkrq as 补考日期,jx_cypxcj.bll as 理论补考,jx_cypxcj.baq as 安检补考,jx_cypxcj.bcz as 操作补考"
            sqlstr = sqlstr & " FROM jx_cypxda INNER JOIN jx_cypxcj ON jx_cypxda.id = jx_cypxcj.xyid"
            sqlstr = sqlstr & "  where jx_cypxda.bmkh=1 and jx_cypxda.jxid = " & ListPxdw.ItemData(ListPxdw.ListIndex)
            If Check1 = 0 Then
                sqlstr = sqlstr & " AND jx_cypxda.pxqc = '" & Listqc & "' and jx_cypxda.zgzshbs <> 1"
            Else '上期学员在本期补考录入成绩后bk=1
                sqlstr = sqlstr & " AND jx_cypxda.pxqc = '" & Val(Listqc) - 1 & "' and jx_cypxda.zgzshbs <> 1 and jx_cypxcj.bk=1"
            End If
            snp1.Open sqlstr, cn
            Call ListRefreshView(ListView1, L, snp1)
            snp1.Close
            chkrows = 0
            LblXycount = "选择:" & chkrows & "/" & L
            Screen.MousePointer = 0
            ListView1.ColumnHeaders.Item(1).Width = 1000
            ListView1.ColumnHeaders.Item(2).Width = 800
            ListView1.ColumnHeaders.Item(3).Width = 1600
            ListView1.ColumnHeaders.Item(4).Width = 1800
        End If
    End SubSub ListRefreshView(ListView1 As ListView, Lcount As Long, snp As ADODB.Recordset)
    Dim i As Long
    Dim ListviewVisible As Boolean
    Dim str As String
    Dim clmX As ColumnHeader
    Dim itmX As ListItem
    Dim ListVisibleMark As Boolean
    PublicEscDown = False
    Screen.MousePointer = 11
    '保持原有显示状态
    ListVisibleMark = ListView1.Visible
    '打开记录集
    On Error GoTo errinfo
    ListView1.ListItems.Clear
    '锁定不刷新
    ListView1.Visible = False
    'LockWindowUpdate ListView1.hwnd'这里的锁定..不如用visible =false 后快....
    With ListView1.ColumnHeaders
        .Clear
        For i = 0 To snp.Fields.Count - 1
            Set clmX = .Add(, , snp.Fields(i).Name, Printer.TextWidth(snp.Fields(i).Name) + 200)
            clmX.Tag = snp.Fields(i).Type
        Next i
        If Not clmX.Index = 1 Then
            clmX.Alignment = lvwColumnLeft
        End If
    End With
    With ListView1
        Do While Not snp.EOF()
            Set itmX = .ListItems.Add(, , "" & snp.Fields(0))
            For i = 1 To snp.Fields.Count - 1
                itmX.SubItems(i) = CStr("" & snp.Fields(i))
            Next
            snp.MoveNext
            DoEvents
            If PublicEscDown Then
                Exit Do
            End If
        Loop
        '记录个数
        Lcount = .ListItems.Count
        
    End With
    'LockWindowUpdate 0&
    '保持原有显示状态
    ListView1.Visible = True 'ListVisibleMark
    Screen.MousePointer = 0
    Exit Sub
    errinfo:
        'ShowError
    End Sub
      

  2.   

    Option ExplicitPrivate Sub Form_Load()LV1.ColumnHeaders.Add , , "序号"
    LV1.ColumnHeaders.Add , , "时间"
    LV1.ColumnHeaders.Add , , "日期"
    LV1.ColumnHeaders.Add , , "备注"Dim itm As ListItemSet itm = LV1.ListItems.Add(, , 1)
    itm.SubItems(1) = "00:00:00"
    itm.SubItems(2) = "2008-01-01"
    itm.SubItems(3) = "(无)"Set itm = LV1.ListItems.Add(, , 2)
    itm.SubItems(1) = "00:00:01"
    itm.SubItems(2) = "2008-01-01"
    itm.SubItems(3) = "(无)"LV1.View = lvwReport
    LV1.FullRowSelect = TrueEnd Sub
      

  3.   

    Private Sub Form_Load()
    ListView1.ColumnHeaders.Add , , "序号"
    ListView1.ColumnHeaders.Add , , "时间"
    ListView1.ColumnHeaders.Add , , "日期"
    ListView1.ColumnHeaders.Add , , "备注"
    ListView1.View = lvwReport
    Set x = ListView1.ListItems.Add(, , "1")
    Set x = ListView1.ListItems.Add(, , "2")Set x = ListView1.ListItems(1).ListSubItems.Add(, , "00:00:00")
    Set x = ListView1.ListItems(1).ListSubItems.Add(, , "2008-01-01")
    Set x = ListView1.ListItems(1).ListSubItems.Add(, , "(无)")
    Set x = ListView1.ListItems(2).ListSubItems.Add(, , "00:00:01")
    Set x = ListView1.ListItems(2).ListSubItems.Add(, , "2008-01-01")
    Set x = ListView1.ListItems(2).ListSubItems.Add(, , "(无)")
    End Sub