listview通过imagelist来显示图像,动态吗?改变imagelist就可以改变listview的图片,
至于打印预览就比较麻烦!至少先来个picturebox,然后......

解决方案 »

  1.   


    listview1.SelectedItem.Icon =loadpicture()
      

  2.   

    先谢谢大家,是在ListView中预览就行,最好有源代码。
    EMAIL:[email protected]
      

  3.   

    Dim X As Integer, Img As Integer
    Dim Y As Long
    Drive1.Refresh
    Dir1.Refresh
    File1.Refresh
    ListView1.ListItems.Clear
    If Mid(Dir1.Path, Len(Dir1.Path), 1) = "\" Then
           strPath = Dir1.Path
     Else: strPath = Dir1.Path & "\"
    End If
    Label1.Caption = strPath
         If Len(Label1.Caption) > 30 Then
            Label1.Caption = "..." & Trim(Right(Label1.Caption, 30))
         End If
    For X = 0 To File1.ListCount - 1
     Img = ImgNumber(File1.List(X))
     With ListView1.ListItems.Add(, , File1.List(X), Img, Img)
      Y = Str(FileLen(strPath & File1.List(X)))
        Dim a  As String
        a = Format((FileLen(strPath & File1.List(X)) / 1000), "### ### ###.##")
        .SubItems(1) = IIf(Y = 0, 0 & "字节", a & "字节")
      ' .SubItems(1) = Format((FileLen(strPath & File1.List(X)) / 1000), "### ### ###.##") & "字节"
        .SubItems(2) = FileDateTime(strPath & File1.List(X))
        .SubItems(3) = Str(FileLen(strPath & File1.List(X)))
    End With
    NextPrivate Function ImgNumber(strFileName As String) As Integer
    Dim strExt As String
        strExt = Mid$(strFileName, InStrRev(strFileName, ".") + 1)
        On Error Resume Next
        Select Case LCase(strExt)
           Case "avi", "mpg", "mpeg", "mov"
                ImgNumber = 8
           Case "gif"
                ImgNumber = 4
           Case "jpg", "jpeg", "jpe", "bmp"
                ImgNumber = 1
           Case "htm", "html", "xml", "asp"
                ImgNumber = 2
           Case "js", "css", "cgi"
                ImgNumber = 5
           Case "mp3", "ram", "au", "vaw"
                ImgNumber = 6
           Case "zip", "arj"
                ImgNumber = 7
           Case "exe", "com", "bat"
               ImgNumber = 9
           Case "txt", "log", "doc", "rtf", "ftp", "ini", "dat"
               ImgNumber = 3
           Case Else
                ImgNumber = 10
        End Select
    End Function