Results 1 to 6 of 6
  1. #1
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    ListBox Scrolling (VBA/Word/2003)

    I have a form which contains a ListBox.

    When I populate the ListBox with more items than it can display in the vertical axis, it provides a vertical scroll bar. I am unable to find any setting which controls this in any fashion. With this I am satisfied. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    When I populate it with a long string, I lose the right hand portion. With this I ain't happy. <img src=/S/weep.gif border=0 alt=weep width=21 height=16>

    Is there some way to:

    <UL><LI>introduce a horizontal scroll bar;
    <LI>cause the list item to wrap to the ListBox horizontal dimension;
    <LI>automatically resize the ListBox and host form to the horizontal dimension adequate to display each list item; or
    <LI>solve my dilemma in some other fashion?[/list]
    If needs be, I can handle this with a MsgBox; but it isn't as user friendly.

    Any guidance will be greatly appreciated.
    Regards
    Don

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ListBox Scrolling (VBA/Word/2003)

    > introduce a horizontal scroll bar;
    No, list boxes don't have a horizontal scroll bar.

    > cause the list item to wrap to the ListBox horizontal dimension;
    No, list boxes don't support text wrapping.

    >automatically resize the ListBox and host form to the horizontal dimension adequate to display each list item;
    Perhaps, but it would be difficult - you'd need to use Windows API functions to determine the width of the string in points, adjust the result for the overhead of the border of the list box, etc. Not an attractive idea.

    > solve my dilemma in some other fashion?
    Yes, don't use long strings in a list box <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  3. #3
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: ListBox Scrolling (VBA/Word/2003)

    Thanks for the clarification Hans. <img src=/S/boxedin.gif border=0 alt=boxedin width=25 height=20>
    Regards
    Don

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: ListBox Scrolling (VBA/Word/2003)

    Have you looked at the ListView control?
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: ListBox Scrolling (VBA/Word/2003)

    Hi Rory
    I cannot locate any ListView control in either the Excel or Word version of VBA. Can you provide a little more info?
    Regards
    Don

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ListBox Scrolling (VBA/Word/2003)

    You have to right-click the Toolbox and select More Controls from the popup menu.
    Scroll down to "Microsoft ListView Control 6.0 (SP6)", tick its check box and click OK.
    This will add the ListView control to the Toolbox.
    You can remove it later (if desired) by right-clicking it in the Toolbox and selecting Remove ListView from the popup menu.

Posting Permissions

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