CompuServe Thread

#listboxes & font size

3 messages in this thread
#3264From: paul bonnerOct 15, 1991 5:02 PM
I'm working on a couple of applications which, as part of their miscellaneous options, offer the user the option to use either a small or large font (actually they toggle between 8.25 and 9.75 points) for displaying text boxes, listboxes, etc. However, I've noticed that when the switch is made, the height of my listboxes changes–sometimes by as much as 50% — more with relatively short listboxes, less with tall ones. This has the tendency to screw up the screen appearance, especially since if you keep toggling back and forth between font sizes at runtime, the listbox keps getting shorter. Is there any way to disable this "feature"? There is 1 Reply.
#3357From: Keith Funk/Vanc.BC,CAN.Oct 16, 1991 1:22 AM
Hi Paul, Ordinary VB ListBox Controls always automatically adjust their height so they don't chop the bottom off the last line in the box. This is what is causing your list boxes to get smaller and smaller as you flip back and forth between text sizes. But have you noticed that at some point, the boxes stop getting smaller and just flip-flop between two heights, one slightly smaller than the other? That is the box height grows slighly smaller or slightly larger as you change text sizes. The change is just enough to make sure that the last line in the box is completely displayed from the top to the bottom of the line. At this point, if you count the number of lines displayed in 8.25 size and 9.75 size, you will find that the ratio is around 1.2 which is very close to the ratio of the text heights. It may even be exactly the same ratio if you take into account leading. Since there is no way within VB to disable the auto-sizing feature of List boxes, I'd like to suggest that you set the box sizes so that they have this 1.2 line count ratio if possible. Try setting your box height so that it displays 22, 11 or 6 lines using 8.25 text. These heights should adjust themselves only a slight amount so that at a text height of 9.75, the box will display 18, 9 and 5 lines respectively. The alternative is to force the List box height to a specified value before changing the text height as in, List1.Height = 3100: List1.FontSize = 9.75. Personally, I found this solution to be visually unappealing because it made the box 'bounce' as it adjusted its size. Has this made any sense?<g>…KeithF There is 1 Reply.
#3404From: paul bonnerOct 16, 1991 11:16 AM
Thanks for the tips. I don't know if that's a perfect solution, but it's good advice. Paul