Remove the scroll bar on a list box

32,991

Solution 1

This can occur when you have the column width format property of the listbox set to something wide, then you size the control to the data, it will show the scroll bars.

To fix this, change the "Column Width" property under the format tab to something really small, then play around with this property and the size of the listbox control until you get it how you want, and no scroll bars are displayed.

Solution 2

You need to set the property ListWidth of the listbox or combobox bigger than the property ColumnWidth.

The first being the size of what you show on screen, and the second being the size of what you want to put inside the first.

Solution 3

As mentioned in other replies, this is a combination of the ColumnWidth and the Width. The main players are

ColumnCount: Listboxes allow the data to snake through multiple columns but that is a different story. For the simple case, set the Column Count to 1

Width: This is set by stretching the drawing

ColumnWidths: This will set the widths of the columns. In the simple case, find out what Width has been set to and subtract the scrollbar width from that value. By default, the Column Width is set to the Width. Since in also includes the size of the vertical scrollbar. The horizontal scrollbar appears if

((sum of columnwidths) + vertical scrollbar width) > (width / column count)

In the simple case, there is only one column width and only one column so the horizontal scrollbar will appear if

(columnwidths + vertical scrollbar width) > width

To find out the scrollbar width, drag a scrollbar on to the canvas. Scroll to the bottom of the properties and find the width. In my case it is 12.75 - make it 12 to simplify the arithmetic.

Worked Example:

Column Count = 1
Width = 48pt
Column Widths = 48 - 12 = 36pt
Share:
32,991

Related videos on Youtube

Mike
Author by

Mike

Just trying to expand my knowledge of coding.

Updated on January 23, 2022

Comments

  • Mike
    Mike over 2 years

    I'm using a userForm in vba and I have a list box. I want to remove the horoz. scroll bar from the bottom. Is there a way to do this? I don't see any option in the properties box.

    enter image description here

  • Mike
    Mike about 13 years
    I tried that. It worked, but I had to make the box really wide. I want to keep it just large enough to view the list.
  • DJ Burb
    DJ Burb about 13 years
    @Mike: Are these values coming from a database or dataset column? If the column length is wider then the listbox, it may add a scrollbar.
  • Mike
    Mike about 13 years
    The values are coming from one of my sheet columns which is just the width of the text inside.

Related