Private Sub ListView1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Deal Button, X, Y
'MsgBox ListView1.SelectedItem.Index
Dim J As Integer '列数
Dim l As Long, I As Long
Dim w As Long
Dim h As Long
If ListView1.ListItems.Count = 0 Then Exit Sub
For J = 1 To ListView1.ColumnHeaders.Count
w = w + ListView1.ColumnHeaders(J).Width
Next
'w = ListView1.Width
J = 0
l = X
If Button = vbLeftButton And w > 0 Then
If l < w - 15 Then
Do While l > 0
J = J + 1
l = l - ListView1.ColumnHeaders(J).Width 'J 为找到第几列数
Loop
Else
Exit Sub
End If
End If
Text1.Left = 100
If J > 1 Then
For I = 1 To J - 1
Text1.Left = Text1.Left + ListView1.ColumnHeaders(I).Width 'text的位置在相应的列
Private Sub ListView1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Deal Button, X, Y
'MsgBox ListView1.SelectedItem.Index
Dim J As Integer '列数
Dim l As Long, I As Long
Dim w As Long
Dim h As Long
If ListView1.ListItems.Count = 0 Then Exit Sub
For J = 1 To ListView1.ColumnHeaders.Count
w = w + ListView1.ColumnHeaders(J).Width
Next
'w = ListView1.Width
J = 0
l = X
If Button = vbLeftButton And w > 0 Then
If l < w - 15 Then
Do While l > 0
J = J + 1
l = l - ListView1.ColumnHeaders(J).Width 'J 为找到第几列数
Loop
Else
Exit Sub
End If
End If
Text1.Left = 100
If J > 1 Then
For I = 1 To J - 1
Text1.Left = Text1.Left + ListView1.ColumnHeaders(I).Width 'text的位置在相应的列
Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim a As Single, Column As Long, i As Long
a = x / 15 - ListView1.SelectedItem.Left
For i = 1 To ListView1.ColumnHeaders.Count
If (ListView1.ColumnHeaders(i).Left <= a) And (a <= ListView1.ColumnHeaders(i).Left + ListView1.ColumnHeaders(i).Width) Then
Column = i
Exit For
End If
Next i
Label1.Caption = Column
End Sub
Private Sub ListView1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
ListView1.ToolTipText = "行数:" & ListView1.ListItems.Count & "列数:" & ListView1.ColumnHeaders.Count
End Sub