Goodmorning :)
I have a ListBox that shows several items (I don't know how many they are), but I'd like that the control can display at most FIVE items per time.
I wrote this code:
This might work but I don't think it's the best solution. In fact, what happens if both the ListBox and the Form use different fonts?
Can you tell me a more elegant solution (if exists) ?
Thanks, :wave:
I have a ListBox that shows several items (I don't know how many they are), but I'd like that the control can display at most FIVE items per time.
I wrote this code:
Code:
Sub ResizeList()
Const MaxItems = 6 'Consider 6 items and let IntegralHeight property to fix.
'WARNING: IntegralHeight = True
Dim Items As Long
Items = List1.ListCont
List1.Height = Form1.TextHeight(List1.List(0)) * IIf(Items > 5, MaxItems, Items)
End Sub
Can you tell me a more elegant solution (if exists) ?
Thanks, :wave: