Private ElemHeight As Single
Private Sub PlacerLignes()
Dim Y As Long
Dim val1 As String, val2 As String
Frame1.Height = ListBox2.Height
ListBox2.Height = ListBox2.ListCount * ElemHeight
Frame1.ScrollHeight = ListBox2.Height
Frame1.Width = ListBox2.Width
For Y = 1 To ListBox2.ListCount - 1
Xval1 = ListBox2.List(Y, 1)
Xval2 = ListBox2.List(Y - 1, 1)
If Xval1 <> Xval2 And Xval2 = "" Then
With Frame1.Controls.Add("Forms.Frame.1")
.Top = Y * ElemHeight
.Left = 0
.Height = 0.68
.Width = 90
.Enabled = False
.SpecialEffect = 0
.BackColor = vbBlack
.ZOrder 0
End With
End If
Next Y
ListBox2.ZOrder 1
End Sub
Private Sub ListBox2_Click()
Dim pos As Single
pos = ListBox2.ListIndex * ElemHeight
If (pos < Frame1.ScrollTop) Or (pos > (Frame1.ScrollTop + Frame1.InsideHeight - ElemHeight)) Then
Frame1.ScrollTop = pos - ElemHeight
End If
End Sub
Private Sub ListBox2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Caption = Y \ ElemHeight
End Sub
Private Sub UserForm_Initialize()
Set f = Sheets("bd")
Tbl1 = f.Range("A2:B" & f.[A65000].End(xlUp).Row).Value
ListBox2.List = Tbl1
If ListBox2.ListCount > 0 Then
Dim acc As IAccessible, d As Long, h As Long
Set acc = ListBox2
acc.accLocation d, d, d, h, 1&
ElemHeight = h * 72 / 96
End If
If ElemHeight = 0 Then
ElemHeight = 9
End If
PlacerLignes
End Sub