字体和背景颜色都可以,只是想和别的行做区分。

解决方案 »

  1.   

    好像只能自画。Private Function SetBackColor(lvList As ListView, picBoard As PictureBox, strItem As String)
        Dim iWidth As Single, iHeight As Single, tHeight As Single, lMatch As Single
        Dim i As Long
        Dim j As Long
        Dim mItems() As String
        Dim intIndex As Double
        
        mItems = Split(strItem, ",")
        With picBoard
            .AutoRedraw = True
            .BackColor = lvList.BackColor
            .Cls
            .Visible = False
            .ScaleMode = vbTwips
            .Width = lvList.Width + 100
            .Height = lvList.ListItems(1).Height * (lvList.ListItems.Count + 1)
            With .Font
                .Size = lvList.Font.Size + 2.75
                .Bold = lvList.Font.Bold
                .Charset = lvList.Font.Charset
                .Italic = lvList.Font.Italic
                .Name = lvList.Font.Name
                .Strikethrough = lvList.Font.Strikethrough
                .Underline = lvList.Font.Underline
                .Weight = lvList.Font.Weight
            End With        iWidth = .Width        For i = 1 To lvList.ListItems.Count
                If i = 1 Then lMatch = lvList.ListItems(i).Top - lvList.ListItems(i).Height
                tHeight = lvList.ListItems(i).Top - lvList.ListItems(i).Height - lMatch
                iHeight = lvList.ListItems(i).Height
                For j = 0 To UBound(mItems) - 1
                    intIndex = CLng(mItems(j))
                    If lvList.ListItems(i).Index = intIndex Then
                        picBoard.Line (0, tHeight)-(iWidth, tHeight + iHeight), vbYellow, BF
                        Exit For
                    Else
                        picBoard.Line (0, tHeight)-(iWidth, tHeight + iHeight), vbWhite, BF
                    End If
                Next
            Next
        End With
        lvList.Picture = picBoard.Image
    End Function这里的strItem是要设置的ListView的Item的Index的集合,以逗号隔开的
    比如要设置背景色的是Index=2,4,6,那么strItem="2,4,6"
      

  2.   

    lvList.Picture 报错,我是VB 6.0怎么没有这个属性
      

  3.   

    不是吧,listview会没这个属性,你看listview的属性窗口能否找到
      

  4.   

    或者自己编程——我也不知道怎么做;或者到网上看看有没有现成的加强版listview控件。DBI的listview好像是可以分别表示颜色的。
      

  5.   

    listview1.ListItems(i).ListSubItems(1).ForeColor =qbcolor(12)
      

  6.   

    to ling242a:
    我用的是5.0组件,sp2系统的。换6.0组件就可以了汗 
      

  7.   

    For j = 0 To UBound(mItems) - 1
    应该改为For j = 0 To UBound(mItems)
    谢谢啦