Ciao
Dopo che hai popolato la tua ListBox, richiama la sub passandogli il nome della list: SetHorizontalBar NomeListBoxcodice:Private Const LB_SETHORIZONTALEXTENT As Long = &H194 Private Const LB_GETTEXTLEN As Long = &H18A Private Declare Function SendMessage Lib "User32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Private Sub SetHorizontalBar(lstBox As ListBox) Dim I As Integer Dim lenTxt As Long Dim maxLenTxt As Single Dim testo As String 'Recupera la lunghezza massima degli elementi della ListBox. For I = 0 To lstBox.ListCount - 1 lenTxt = SendMessage(lstBox.hwnd, LB_GETTEXTLEN, I, ByVal 0) If lenTxt > maxLenTxt Then testo = lstBox.List(I) maxLenTxt = lenTxt End If Next I maxLenTxt = Me.TextWidth(testo) If Me.ScaleMode = vbTwips Then maxLenTxt = maxLenTxt / Screen.TwipsPerPixelX 'Visualizza la barra di scorrimento orizzontale. SendMessage lstBox.hwnd, LB_SETHORIZONTALEXTENT, maxLenTxt, 0& End Sub
![]()

Rispondi quotando