• Listbox format (2002/SP3)

    Author
    Topic
    #458154

    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?

    Viewing 3 reply threads
    Author
    Replies
    • #1151092

      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?

      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.

      • #1151288

        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.

        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?

        • #1151289

          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.

          • #1151336

            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?

            • #1151338

              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?

              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″]Post 754457[/post].

    • #1178715

      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?

      • #1178717

        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.

        • #1178721

          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.

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

          • #1178725

            Are you sure?

            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?

    • #1178731

      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.

    • #1178732

      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?

      • #1178735

        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.

        • #1178982

          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.

          Thanks Hans,

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

    Viewing 3 reply threads
    Reply To: Listbox format (2002/SP3)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: