PowerApps - Building a Expanding Gallery with a Expanding Text Box

I recently built a questionnaire PowerApp for a customer.  They had a bunch of questions where the expected answers could be anything from 50-500 words. The problem was when you put too many words into a text box, it gets scroll bars. eww.

I'm not against scrollbars for a whole screen, but for text boxes, yeah no. So here's what we did!
  • Added a 'Blank Flexible Height' Gallery to the PowerApp
  • Connected it to my Collection of questions
  • Added a label to display the question
  • Added a text box to collect the answers
  • Set the following text box properties:
    • Mode: Multiline
    • Height: 40 * RoundUp((Len(TextInput1.Text)+0.01) / 90,0)

What this does

  • 40 - how tall the text box is each time you meet the character limit for one line
  • 90 - How many characters it takes to move the 40px multiplier up 
  • roundup - ensures the returned number is only ever 1 rounded number.  This means the text box grows in chunks, instead of growing with each individual character typed.
  • +0.01 - ensures that even if the text box is empty, it's minimum height will be 40px
Screen showing the Full Tested PowerApp & Height property
Before text has been added
After text has been added
Thank you to Clifton who got me started down the right path: https://www.xylos.com/en/corporate/blog/powerapps-automatically-adjust-size-text-box

Comments

Popular posts from this blog

How to Copy/Duplicate a Table and Columns in a Dataverse Environment

Export Group Membership From Active Directory Using Power Query

Microsoft Flow - Apply To Each Limitation (5000 items)