Setting textbox text value on button click
Asked Answered
A

2

5

I have a from in PowerApps with labels and textboxes. By default textboxes are empty. There is a Button named "Copy last row" when use will click on this button some sample values should be displayed in textboxes.

I checked on internet and the following solution was suggested by PowerApp support.

You need to set the text box' text property to this:

 If(HasBeenPressed, "Hello", "GoodBye")  

You also need to set the button's onselect property to this:

UpdateContext({HasBeenPressed: true})

or for more fun,

UpdateContext({HasBeenPressed: !HasBeenPressed})

But when I go to the properties of my textbox there is no such property like 'TEXT'.

Aeroneurosis answered 6/12, 2019 at 11:42 Comment(1)
Could you provide any code or something? Please see stackoverflow.com/help/how-to-askPiglet
A
8

What do you mean by textbox? a label or a text-input?

Anyways, Label has a text property: enter image description here

Text-input has a default property enter image description here

I'm afraid u can't change the text directly. What u can do is create a context variable in the property "OnVisible" of your screen and give the default text you want your labels to have in the first place, or leave the variable in blank since you want them to have no text:

On visible context variable enter image description here

Then, set the text property of your label to be the value inside the variable enter image description here

Or the default property of your text-input enter image description here

Last but not least, set the OnSelect property of your button to change the value of your variable: enter image description here

This is the result: enter image description here

Hope this helps!

Autogiro answered 6/12, 2019 at 18:9 Comment(3)
Thank you @Bruno . It works fine for me and from textbox I meant text-input.Aeroneurosis
I'm glad it helped you! If this reply answers your question, please mark it as answer. Best RegardsAutogiro
To mark an answer as accepted, click on the check mark beside the answer to toggle it from greyed out to filled in. stackoverflow.com/help/someone-answersAutogiro
B
2

Adding clarifications on top of Bruno's demonstrating answer.

In Canvas PowerApps, both Label & Text input controls have the Text property.

But Text is Output only property for Text input control whereas for Label its of both type ie. input and output property. People (bloggers/trainers) often mix these controls & properties.

enter image description here

Text is an Output property on that control, to be consumed by other controls. You can't set it manually as it is not an Input property. The Default property determines its initial content.

by PowerApps staff on PowerApps forum

Brodeur answered 6/12, 2019 at 20:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.