listview的view属性为lvwList 2 列表
在执行显示的时候
只能显示前10个字符
即列表中的数据显示为:
3333333333...
wwwwwwwwww...
ssdfdfdgsf...
怎样才能都显示出来呢?

解决方案 »

  1.   

    使用 lvwReport 应该可以吧
      

  2.   

    Private Sub Form_Load()
        ListView1.View = lvwList
        
        Dim itemx As ListItem
        Dim i As Integer
        Dim j As Integer
        Dim iCount As Integer
        Dim x As String
        iCount = 10
        
        With ListView1
            For i = 1 To iCount
                x = "lxcc"
                For j = 1 To CInt(20 * Rnd(j * Timer))
                    x = x & Chr(95 + i)
                Next
                Set itemx = .ListItems.Add(, , IIf(Len(x) >= 10, Left(x, 10) & "...", x))
            Next
        End With
        
    End Sub
      

  3.   

    自己调整listview的列宽度也可以做到!
      

  4.   

    to:lxcc(虫子) 
    我想您误会我的意思了,我现在是想全部显示出来,但不知为什么只能显示一部分!
      

  5.   

    Declare Function GetLongPathName Lib "kernel32.dll" Alias "GetLongPathNameA" ( _ 
     ByVal lpszShortPath As String, _ 
     ByVal lpszLongPath As String, _ 
     ByVal cchBuffer As Long) As Long 这个行吗?
    你说的是短文件名吗?我曾经显示文件的路径,结果得到了
    x:\dfadsfasd\sdafasdf\dadsfsd~.txt
    这样,用这个api搞定
      

  6.   

    改为lvwReport试下
    可以全部显示出来的
      

  7.   

    抱歉!看错了!Private Sub Form_Load()
        Dim itemx As ListItem
        Dim chead As ColumnHeader
        Dim i As Integer
        Dim iCount As Integer
        iCount = 10
        
        With ListView1
            For i = 1 To iCount
                Set itemx = .ListItems.Add(, , "asdjaskjdhakasdasdasdasdas")
            Next
            
            .View = lvwReport
            Set chead = .ColumnHeaders.Add(, , "Test", 3200)
            .HideColumnHeaders = True
        End With
        
    End Sub
      

  8.   

    简单:
            listview1.ColumnHeaders(1).Width=listview1.with*0.2  ''或者设一个够用的宽度
      

  9.   

    参考一下,应该对你有用:):
    Private Sub lvwUser_ItemClick(ByVal Item As MSComctlLib.ListItem)
        Dim intCount As Integer
    '    If Item.Index = lvwUser.ListItems.Count Then
    '        txtUser.Text = Left(Item.Text, Len(Item.Text) - 1)
    '    Else
            txtUser.Text = Item.Text
    '    End If
        txtPassword.Text = Item.SubItems(1)
        For intCount = 1 To 6
            chkSetting(intCount - 1).Value = 0
        Next
        
        For intCount = 1 To Len(Item.SubItems(2))
            Select Case Mid(Item.SubItems(2), intCount, 1)
                Case "1"
                    chkSetting(0).Value = 1
                Case "2"
                    chkSetting(1).Value = 1
                Case "3"
                    chkSetting(2).Value = 1
                Case "4"
                    chkSetting(3).Value = 1
                Case "5"
                    chkSetting(4).Value = 1
                Case "6"
                    chkSetting(5).Value = 1
            End Select
        Next
    End Sub
    Private Sub Option1_Click(Index as Integer)
       ' These OptionButtons offer two choices: Ascending (Index 0), 
       ' and Descending (Index 1). Clicking on one of these
       ' sets the SortOrder for the ListView control.
       ListView1.SortOrder = Index
       ListView1.Sorted = True ' Sort the List.
    End SubPrivate Sub Form_Load()
       ' Create an object variable for the ColumnHeader object.
       Dim clmX As ColumnHeader
       ' Add ColumnHeaders. The width of the columns is the width
       ' of the control divided by the number of ColumnHeader objects.
       Set clmX = ListView1.ColumnHeaders. _
       Add(, , "Company", ListView1.Width / 3)
       Set clmX = ListView1.ColumnHeaders. _
       Add(, , "Address", ListView1.Width / 3)
       Set clmX = ListView1.ColumnHeaders. _
       Add(, , "Phone", ListView1.Width / 3)   ListView1.BorderStyle = ccFixedSingle ' Set BorderStyle property.
       ListView1.View = lvwReport ' Set View property to Report.   ' Label OptionButton controls with SortOrder options.
          Option1(0).Caption = "Ascending (A-Z)"
          Option1(1).Caption = "Descending (Z-A)"
          ListView1.SortOrder = lvwAscending ' Sort ascending.    ' Create object variables for the Data Access objects.
       Dim myDb As Database, myRs As Recordset
       ' Set the Database to the BIBLIO.MDB database.
       Set myDb = DBEngine.Workspaces(0).OpenDatabase("BIBLIO.MDB")
       ' Set the recordset to the Publishers table.
       Set myRs = myDb.OpenRecordset("Publishers", dbOpenDynaset)
          
       ' Create a variable to add ListItem objects.
       Dim itmX As ListItem   ' While the record is not the last record, add a ListItem object.
       ' Use the Name field for the ListItem object's text.
       ' Use the Address field for the ListItem object's subitem(1).
       ' Use the Phone field for the ListItem object's subitem(2).   While Not myRs.EOF
          Set itmX = ListView1.ListItems.Add(, , CStr(myRs!Name))      ' If the Address field is not Null, set subitem 1 to the field.
          If Not IsNull(myRs!Address) Then
             itmX.SubItems(1) = CStr(myRs!Address)  ' Address field.
          End If      ' If the Phone field is not Null, set subitem 2 to the field.
          If Not IsNull(myRs!Telephone) Then
             itmX.SubItems(2) = myRs!Telephone  ' Phone field.
          End If      myRs.MoveNext   ' Move to next record.
       Wend
    End SubPrivate Sub ListView1_ColumnClick(ByVal ColumnHeader As ColumnHeader)
       ' When a ColumnHeader object is clicked, the ListView control is
       ' sorted by the subitems of that column.
       ' Set the SortKey to the Index of the ColumnHeader - 1
       ListView1.SortKey = ColumnHeader.Index - 1
       ' Set Sorted to True to sort the list.
       ListView1.Sorted = True
    End Sub
      

  10.   

    在VB中用lenb(STR)来检测字节数,再用每个字节宽度*字节数可得出每一列的宽度,记得将ListView的View设为lvwReport即OK