必须OwnerDraw,但很麻烦,不值得使用。 关于水平滚动条,可以这样加: Private Const LB_SETHORIZONTALEXTENT = &H194 Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Sub SetHorScorll(ByVal DestList As ListBox) Dim lWidth As Long, lWidthMax As Long, i As Long For i = 0 To DestList.ListCount - 1 lWidth = Me.TextWidth(DestList.List(i)) + 20 If lWidth > lWidthMax Then lWidthMax = lWidth Next SendMessage DestList.hwnd, LB_SETHORIZONTALEXTENT, lWidthMax, lWidthMax End Sub 另:就算用ListView,也需要OwnerDraw :(
关于水平滚动条,可以这样加:
Private Const LB_SETHORIZONTALEXTENT = &H194
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Sub SetHorScorll(ByVal DestList As ListBox)
Dim lWidth As Long, lWidthMax As Long, i As Long
For i = 0 To DestList.ListCount - 1
lWidth = Me.TextWidth(DestList.List(i)) + 20
If lWidth > lWidthMax Then lWidthMax = lWidth
Next
SendMessage DestList.hwnd, LB_SETHORIZONTALEXTENT, lWidthMax, lWidthMax
End Sub
另:就算用ListView,也需要OwnerDraw :(