Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

List Boxes - need to autosize

Newbie_Julie
Level 2
Level 2

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.

Is it possible to do this? If so, how?
Thanks -- Julie
0 Replies
pguerett
Level 10
Level 10

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.

Paul

westlakejager
Level 3
Level 3

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

Steve_L_Walker
Level 10
Level 10

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.

// form1.page1.lb::initialize - (JavaScript, client)


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'.

Steve