Message 1 of 1
Listbox with Horizontal Scrollbar (Solution)

Not applicable
04-16-2007
09:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
While driving myself crazy trying to find a solution for adding a Horizontal
Scrollbar to a Listbox, in VBA, I found the following partial solution.
Which adds the scrollbar, but does not take into account the Width of the
longest string of text in the Listbox.
http://discussion.autodesk.com/thread.jspa?messageID=385338
The workaround I came up with is to add a hidden Textbox, with
Autosize=True, to the Form, step through each item in the Listbox while
setting the Text of the Textbox to the string, check the Width of the
Textbox, while comparing it the previous Width to find the Max, and set the
width of the Listbox to the Max width.
Please note that the font properties should be the same for both the Listbox
and the Textbox.
I hope someone finds this helpful and clear.
Jim Dee
www.caddee.com
Scrollbar to a Listbox, in VBA, I found the following partial solution.
Which adds the scrollbar, but does not take into account the Width of the
longest string of text in the Listbox.
http://discussion.autodesk.com/thread.jspa?messageID=385338
The workaround I came up with is to add a hidden Textbox, with
Autosize=True, to the Form, step through each item in the Listbox while
setting the Text of the Textbox to the string, check the Width of the
Textbox, while comparing it the previous Width to find the Max, and set the
width of the Listbox to the Max width.
Please note that the font properties should be the same for both the Listbox
and the Textbox.
I hope someone finds this helpful and clear.
Jim Dee
www.caddee.com