Skip navigation
Newbie Julie
Currently Being Moderated

List Boxes - need to autosize

Aug 3, 2010 12:48 PM

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
 
Replies
  • Currently Being Moderated
    Aug 3, 2010 1:04 PM   in reply to Newbie Julie

    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

    Attachments:
     
    |
    Mark as:
  • Currently Being Moderated
    Aug 3, 2010 1:16 PM   in reply to Newbie Julie

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 3, 2010 2:11 PM   in reply to Newbie Julie

    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

    Attachments:
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points