We have a form in Workspace ES 8.2 that uses list boxes that are populated dynamically. Currently when we show a list box only two items can be fully seen in the list as that is the initial size of the box on the form. We need the list box to expand (if needed) to show all the items in the list--whether that's 2 or 7 or 15.
You can change its size dynamically. I created a sample for you to follow. You will have to adjust the growfactor to suit your needs
as it will be dependant on font size.
Nothing special, but I entered this into the list box initialize script as FormCalc (the .225 was the standard height for each list item for me, depending on font and size, you can play around):
this.h = ListBox1.length*.225
You can change the list box height attribute based upon the number of items that are to be bound to the list box object instance.
A list box containing 2 items is about 0.7 inches in height. Designer changes that in the XML source to 17.78 mm. That includes the top and bottom margins for the value and margin for the caption. So I am going to call the list box to be 15 mm in height for 2 items. Each item in the list requires about 5 mm of height.
I attached the script, below, to the initialize event of the list box. The variable 'dataSource' is intended to mimic the number of items to be bound to the list box. This could be the the length of the array you are binding to the list box, for example.
var dataSource = 5;
var h_ = 15 + ((dataSource - 2) * 5);
h_ = h_.toString() + "mm"
form1.page1.lb.h = h_;
You can test by adding/changing the number of items statically bound to list box and changing the value of 'dataSource'.