Skip to main content

Hi,

 

Anyone know how to display more than 5 items in a List Box at runtime?

Got a list box with 9 static values, when you run the form, only 5 are shown, the rest the user has to scroll down (which isn't that obvious).

 

How do you increase the height of the List View to auto adjust according to the number of Static values?

 

Thanks

On the General properties pane for the List Box, if you change the Height value to a larger pixel count (default is 175px), this will make the box larger to show more values.


 


To make this dynamic, you can use an expression to build the value you want to set the list box's control properties. The way I had to do it is to create a list view that I keep hidden on my form that loads the values you are also loading into the list box, add a count to one of the rows, then use that count data label to control the value you will pass into the height property of the list box control. I found that multiplying the count of the list by 32 gave me a sweet spot that eliminates the scroll bar no matter what resolution is set or zooming is applied to the browser, but you can tweak this value to find what best suits your needs. The specific theme you are using might change how it is rendered as well, so it will be important to take that into account.


 


I attached an image that shows how I built my expression.




K2 will not accept any liability for any issues arising from actions taken in respect of the information provided by any forum member. Please kudo my post if it's helpful, or mark as the solution if it answers your query.



Thanks Jered, that gave me a few ideas to try.

As the number of rows is fixed, I just set the value directly, rather than use List View and count.

Tested it on a couple of different devices and it worked well.

 

Nice one!


Reply