⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clistview.cls

📁 设置IP地址工具
💻 CLS
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "CListView"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit


Dim m_Rows As Long
Dim m_Cols As Long
Dim WithEvents myList As ListView
Attribute myList.VB_VarHelpID = -1

Public Property Let Rows(lngRows As Long)
    m_Rows = lngRows
End Property
Public Property Get Rows() As Long

    Rows = m_Rows
     
End Property

Public Property Let Cols(lngCols As Long)
    m_Cols = lngCols
End Property
Public Property Get Cols() As Long
    Cols = m_Cols
End Property

Public Sub Attach(itList As ListView)

    Set myList = itList
    
End Sub

Public Sub Clear()
    
    myList.ColumnHeaders.Clear
    
End Sub

'通过拆分字符的方式给标题赋值,其中拆分符号为“|”
Public Sub setHead(strHead As String, Optional intViewMode As Integer = lvwReport)

    Dim strSplit
    Dim i   As Integer
    If strHead = "" Then Exit Sub
    
    myList.View = intViewMode
    strSplit = Split(strHead, "|")
    For i = 0 To UBound(strSplit)
        myList.ColumnHeaders.Add = strSplit(i)
    Next i
    m_Cols = myList.ColumnHeaders.Count
    
End Sub
 
'设置平均宽度,有特殊的具体调节
Public Sub SetWidth(intWidth As Integer)

    Dim i As Integer
    
    For i = 1 To myList.ColumnHeaders.Count - 1
        myList.ColumnHeaders(i).Width = intWidth
    Next i

End Sub

Private Sub myList_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
    With myList '点击列标头排序
        If (ColumnHeader.Index - 1) = .SortKey Then
            .SortOrder = (.SortOrder + 1) Mod 2
        Else
            .Sorted = False
            .SortOrder = 0
            .SortKey = ColumnHeader.Index - 1
            .Sorted = True
        End If
    End With
End Sub




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -