Results 1 to 14 of 14
  1. #1
    2 Star Lounger
    Join Date
    Oct 2008
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have put a listbox on a userform. Sometimes I have a long text on one line and I would like to scroll horizontally if the text goes beyond the width of the control. What I would like to know is how can you allow for the horizontal scroll bar to appear on this control?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    [quote name='CFDguru' post='764452' date='09-Mar-2009 21:00']I have put a listbox on a userform. Sometimes I have a long text on one line and I would like to scroll horizontally if the text goes beyond the width of the control. What I would like to know is how can you allow for the horizontal scroll bar to appear on this control?[/quote]
    If you set the ColumnWidths property of the list boxto a large enough number, the list box will display a horizontal scroll bar.
    It's not easy, however, to make the ColumnWidths just large enough to fit the text, since you probably use a proportional font.

  3. #3
    2 Star Lounger
    Join Date
    Oct 2008
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='764467' date='09-Mar-2009 16:37']If you set the ColumnWidths property of the list boxto a large enough number, the list box will display a horizontal scroll bar.
    It's not easy, however, to make the ColumnWidths just large enough to fit the text, since you probably use a proportional font.[/quote]
    Thanks Hans. Can you control the appearance of a horizontal scroll bar such that if the text fits within the current width of listbox then a scroll bar won't show up, and if the full length of the text that appears within the listbox is beyond the width of the listbox then a horizontal scroll bar would appear? If so, how?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    [quote name='CFDguru' post='764579' date='10-Mar-2009 14:30'][/quote]
    No, the appearance of the scroll bar depends on the width of the list box and the combined ColumnWidths, not on the actual text displayed in the list box.

  5. #5
    2 Star Lounger
    Join Date
    Oct 2008
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    One last question. As you can see from the attached figure, I get these dotted lines that disrupt the view in the listbox when I scroll from left to right, and back again. Any idea how I can avoid this from happening?
    Attached Images Attached Images

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    [quote name='CFDguru' post='764653' date='10-Mar-2009 18:22']One last question. As you can see from the attached figure, I get these dotted lines that disrupt the view in the listbox when I scroll from left to right, and back again. Any idea how I can avoid this from happening?[/quote]
    That's a glitch of your video card. Make sure that you have the latest driver for your video card.

    You can experiment with hardware acceleration (if you don't have Windows Vista or later), see Post 754457.

  7. #7
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New England (Connecticut)
    Posts
    200
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Is it also possible to right justify data in a list box? I have a query populating a list box with one field shoing standard numbers. (i.e. 123,456,789 with no decimals). However it is left justified and the numbers do not lign up if they are different lengths. Can that field be formatted to display as right justified?
    Kevin

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    In the Visual Basic Editor, open the userform.
    Click on the list box to select it.
    In the Properties pane, set the TextAlign property to 3 - fmTextAlignRight.

  9. #9
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New England (Connecticut)
    Posts
    200
    Thanks
    1
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='794947' date='25-Sep-2009 21:23']In the Visual Basic Editor, open the userform.
    Click on the list box to select it.
    In the Properties pane, set the TextAlign property to 3 - fmTextAlignRight.[/quote]


    My properties for that list box do not show a text align property
    Kevin

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Are you sure?

    [attachment=85696:x.png]

    Oh wait - are you talking about a list box on a userform in Excel (that's what this topic is about)? Or about another kind of list box?
    Attached Images Attached Images
    • File Type: png x.png (15.1 KB, 0 views)

  11. #11
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New England (Connecticut)
    Posts
    200
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hans,
    I can't be in the same place you are unless it is a difference in versions. I am using Office 2003 SP 3. I can see everything else you are showing in your screen shot except textalign.
    Kevin

  12. #12
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New England (Connecticut)
    Posts
    200
    Thanks
    1
    Thanked 0 Times in 0 Posts
    HANS,

    Sorry, I did a search in the ACCESS topic but it must have brought up the Excel. This is an Access question. My bad. Still possible?
    Kevin

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    List boxes in Microsoft Access do *not* have a TextAlign property. They are left-aligned by default.

    You'd need Windows API functions to change that; Stephen Lebans has a sample database with the necessary code: JustiCombo.

  14. #14
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New England (Connecticut)
    Posts
    200
    Thanks
    1
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='794966' date='25-Sep-2009 22:13']List boxes in Microsoft Access do *not* have a TextAlign property. They are left-aligned by default.

    You'd need Windows API functions to change that; Stephen Lebans has a sample database with the necessary code: JustiCombo.[/quote]


    Thanks Hans,

    Its probably easier to use a continuous subform for now. I appreciate your help.
    Kevin

Posting Permissions

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