PowerApps 中的 Reset 函数Reset function in PowerApps

将控件重置为默认值,放弃任何用户更改。Resets a control to its default value, discarding any user changes.

说明Description

Reset 函数将控件重置为其 Default 属性值。The Reset function resets a control to its Default property value. 将放弃任何用户更改。Any user changes are discarded.

不能从编辑表单控件外部重置这些控件内部的控件。You cannot reset controls that are within a Gallery or Edit form control from outside those controls. 可以在同一个库或表单中的控件上,通过公式重置控件。You can reset controls from formulas on controls within the same gallery or form. 也可以使用 ResetForm 函数重置表单中的所有控件。You can also reset all the controls within a form with the ResetForm function.

使用 Reset 函数可用于替换切换输入控件的 Reset 属性,并且通常首选此方法。Using the Reset function is an alternative to toggling the Reset property of input controls and is generally preferred. 需要从多个公式同时重置许多控件时,Reset 属性可能是更好的选择。The Reset property may be a better choice if many controls need to be reset together from multiple formulas. 可以使用 Reset = Button.Pressed 公式通过按钮控件,或通过变量(使用 Reset = MyVar 并使用 Button.OnSelect = Set( MyVar, true ); Set( MyVar, false ) 公式切换 MyVar),完成切换 Reset 属性。Toggling the Reset property can be done from a Button control with the formula Reset = Button.Pressed or from a variable with Reset = MyVar and toggling MyVar with the formula Button.OnSelect = Set( MyVar, true ); Set( MyVar, false ).

输入控件的 Default 属性更改时,输入控件也将重置。Input controls are also reset when their Default property changes.

Reset 没有返回值,只可以在行为公式中使用它。Reset has no return value, and you can use it only in behavior formulas.

语法Syntax

Reset( Control )Reset( Control )

  • Control – 必需。Control – Required. 要重置的控件。The control to reset.

示例Example

  1. 在屏幕上插入“文本输入”控件。Insert a Text input control on a screen. 默认情况下,其名称为 TextInput1,且其 Default 属性将设置为 "Text input"By default, it's name will be TextInput1 and its Default property will be set to "Text input".
  2. 在文本框中键入新值。Type a new value in the text box.
  3. 在屏幕上插入“按钮”控件。Insert a Button control on the screen.
  4. 将该按钮的 OnSelect 属性设置为 Reset( TextInput1 )Set the button's OnSelect property to Reset( TextInput1 ).
  5. 选择此按钮。Select the button. 即使选择在控件的末尾进行创作,也可以执行此操作。This can be done even when authoring by selecting toward the ends of the control.
  6. 文本框的内容将返回到 Default 属性的值。The contents of the text box will return to the value of the Default property.