Xylos brands

PowerApps: how to automatically adjust the text box

You’re probably familiar with the AutoHeight property in PowerApps. Unfortunately, the Text Input control doesn’t include this property, which means you have to work with a vertical scroll bar – and sometimes, you just need to be able to view your entire text at once. So, is there a way to automatically adjust the size of the text box?

If you play it smart, you can mimic this property, so that the text box doesn’t clog up unnecessary screen space and expands as needed.

How do I do this?

For instance: if a new line starts after every 23 characters and my lines are 34 mm high, then the formula is as follows:

Height = 34 mm x (no. of words / 23)

In PowerApps Syntax, this becomes:

Height =    34    * (RoundUp(Len(TextInput1.Text),0 / 23))

What does this formula mean?

  • 34 is the desired line height. In this example, the value is 34 mm.
  • RoundUp function rounds up the number if the result is a fraction.
  • Len function counts the number of characters in a string.
  • The string’s content is described in TextInput1.Text control.
  • The number 0 indicates the amount of decimal places.
  • 23 indicates the number of characters per line.

Not convinced yet?
Give it a try!

Looking for training tailored to the needs of your company? Contact my colleagues in our Learning Team for more information.

Share this blogpost

Also interesting for you

Comments

Brett R
06/12/2018

Thanks for this, I slightly modified so that it doesn't slowly grow each character, but only grows by 40 pixels every time you add more than 90 characters.

The 0.01 is so if you have NO text in the box, it still is at least 40px high :)

40 * RoundUp((Len(txt_Section1Answer_6.Text)+0.01) / 90,0)

Cindy
04/01/2019

Thanks to both of you! Not what I was looking for when I found it but still super duper helpful!

GerardBew
13/01/2019

cialis without prescription
buy cialis without a doctor's prescription cialis without a doctor's prescription buy cialis without a doctor's prescription cialis without prescription online

Leave a reply

Your email address will not be published. Required fields are marked.