Horizontal scrolling on List Box controls

The VBA UserForm List Box control automatically adds a vertical scrollbar when the number of lines exceeds what can be displayed. The same is not true for lines that exceed the width of the control, as shown in the image below.

CAD Training

To remedy this many developers will extend the width of the List Box control to encompass their longest lines. This can result in messy looking and very large dialogs that get in the way of other windows you want to view simultaneously. It is possible to add a horizontal scrollbar to a List Box control by editing the ColumnWidths property of the control. Making the ColumnWidth value greater than the Width value of the control will add a horizontal scrollbar.

CAD Training

After modifying the ColumnWidths property run the macro again and a horizontal scroll bar will be available for the List Box. Adjust the ColumnWidths property as necessary to accommodate your longest lines.

CAD Training

Rod Wing

Rod Wing

Rod joined EnvisionCAD in March 2007 and has nearly three decades of experience working in the CADD industry. He led the IT evaluations of Bentley InRoads and AutoDesk Civil 3D at Wisconsin DOT in their overall CAiCE replacement evaluation. He also led the MicroStation V7 to V8 upgrade effort at Wisconsin DOT which included updating not only the CADD standards to accommodate the changes in the file format but also updating legacy MDL and macros to work in the new environment. Rod received a Bachelor of Science degree from the University of Wisconsin in Cartography and a Master of Science in Geographic and Cartographic Sciences from George Mason University. Rod has extensive experience in CADD as well as the areas of GIS, cartography, plotting, scanning, raster editing/manipulation, publishing, and file/data translations. In all of these areas, he has produced custom tools and developed workflows to enhance productivity between diverse sets of applications. He instructs MicroStation classes ranging from fundamentals to advanced applications.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *