expand a listbox to fit query?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • StarryNight
    New Member
    • Jul 2008
    • 9

    expand a listbox to fit query?

    Hi everyone,
    is it possible to expand a listbox based on what is queried to it? The listboxes I have bring up records depending on whawt is queried, but because I have 20 listboxes doing this I would like to minimize the amount of space that they take. Sometimes the set size is too small and the the listbox will go into scroll mode (I need to print the results in the listboxes so scrolling listboxes don't work). Does anyone have any ideas?
  • FishVal
    Recognized Expert Specialist
    • Jun 2007
    • 2656

    #2
    Hello, StarryNight.

    Though you may easily change ListBox height and position using Listbox.Height, Listbox.Left and Listbox.Top properties, I think there is no "native" way to fit ListBox height.

    You may use an approach similar to that described in The Bytes Tip of the Week - How to Dynamically set the Combo Drop Down List Width to determine text height.

    You may estimate an appropriate height increment per listbox row manually and use it as long as listbox font does not changes.

    Regards,
    Fish

    Comment

    • StarryNight
      New Member
      • Jul 2008
      • 9

      #3
      thanks Fish,
      considering my skill level, I'm going to have to think 'around' the problem. However, having your input is helping narrow my focus.
      thanks.

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        Of course, what hasn't been said, but should be, is that you shouldn't be printing forms, you should be using reports to print . Having said that

        Me.YourListBoxN ame.Height = YourListBoxName .ListCount * (0.15 * 1440)

        will set the height correctly, assuming that you're using the default font Tahoma with the default size of 8. With other font/sizes you'd have to experiment with the

        0.15

        number. You'd also have to think about what happens if the wuery returns more items than your form has room to display.

        Welcome to Bytes!

        Linq ;0)>

        Comment

        Working...