changing height of listbox based upon number of records

  • Thread starter Thread starter Hcoms
  • Start date Start date
H

Hcoms

Hello ,

How can you change the height of a listbox based upon the number of records
that are in the listbox? This is to try and avoid the scroll bars.

Any help would be greatly appreciated!
 
there is no automatic way, but you can write some code:
1. calcualte how much one row in pixels
in form load:
2. run DCount() on listbox rowsosurce to get number of rows
3. multiply by number in 1
4. adjust height - me.listbox1.height= <new value>

probably you have to compare possible heigh with form section height, you
cant make control higher then form section
 
Thank you i just had to get the pixel height from the text to calculate the
new height.

Cheers
 
Back
Top