How do I change the font size in an Excel listbox?

  1. I know a listbox is supposed to expand its height so that it never displays a portion [height] of the last. However, in the following code, when I keep changing the fontsize, the listbox [list1] sometimes gets shorter. Original size was 6540, but when clicking on the commandbutton [cmd1], that changes. At some point, the list1.height equaled 300 [but that will change when clicking again]. I have added 'list1.height = 6540" after changing the fontsizes, but I would not think that would be necessary. Is there some property to set in the listbox to keep it from shrinking as it does in this example?
    Private Sub cmd1_Click[Index As Integer] If Index = 0 Then 'increase font Select Case List1.fontsize Case 8.25 List1.fontsize = 10 Case 9.75 List1.fontsize = 12 Case 12 List1.fontsize = 14 Case 13.5 List1.fontsize = 18 Case 18 MsgBox ["This is the largest allowed font size."] list1.height = 6540 Exit Sub End Select Else 'decrease font Select Case List1.fontsize Case 8.25 MsgBox ["This is the smallest allowed font size."] list1.height = 6540 Exit Sub Case 9.75 List1.fontsize = 8.25 Case 12 List1.fontsize = 10 Case 13.5 List1.fontsize = 12 Case 18 List1.fontsize = 14 End Select End If list1.height = 6540 End Sub
  2. Re: Listbox changes height [a lot] when changing fontsize

    I'm fairly sure the auto-sizing only occurs if the IntegralHeight property is True, making it False may well do what you want.
  3. Re: Listbox changes height [a lot] when changing fontsize

    Thanks....did the trick. Don't know WHY, as that property is used for making sure the entire last line is visible [height-wise]; but, you are correct, it works fine set to False.
  4. Re: [RESOLVED] Listbox changes height [a lot] when changing fontsize

    Use a Timer and then call the Resize event everytime the Font is entered into the ListBox, using a Text String Entry???
    or
    Use the ListBox's Change event to call the Resize event, everytime the ListBox is changed in some shape or form???

    -- Either one is good, but I will go for the latter, it's just better that way!!

    I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...

    |Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Event's Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Bar | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern |

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Forum Rules

Click Here to Expand Forum to Full Width

Video liên quan

Chủ Đề