PowerApps 中的文字輸入控制項Text input control in PowerApps

方塊,使用者可以在其中輸入文字、數字和其他資料。A box in which the user can type text, numbers, and other data.

說明Description

使用者可以藉由輸入到文字輸入控制項來指定資料。The user can specify data by typing into a text-input control. 根據您設定應用程式的方式,資料可能會新增至資料來源,用來計算暫存值,或以其他方式納入。Depending on how you configure the app, that data might be added to a data source, used to calculate a temporary value, or incorporated in some other way.

主要屬性Key properties

Default – 控制項在使用者變更之前的初始值。Default – The initial value of a control before it is changed by the user.

Text – 控制項上顯示的文字,或使用者在控制項中輸入的文字。Text – Text that appears on a control or that the user types into a control.

其他屬性Additional properties

Align – 文字相對於其控制項水平中心的位置。Align – The location of text in relation to the horizontal center of its control.

BorderColor – 控制項框線的色彩。BorderColor – The color of a control's border.

BorderStyle – 決定控制項的框線為實線虛線點線BorderStyle – Whether a control's border is Solid, Dashed, Dotted, or None.

BorderThickness – 控制項框線的粗細。BorderThickness – The thickness of a control's border.

FocusedBorderThickness – 控制項具有鍵盤焦點時的框線粗細。FocusedBorderThickness – The thickness of the control's border when it has keyboard focus.

Clear – 文字輸入控制項是否顯示 "X",使用者可以點選或按一下以清除該控制項的內容。Clear – Whether a text-input control shows an "X" that the user can tap or click to clear the contents of that control.

Color – 控制項文字的色彩。Color – The color of text in a control.

DelayOutput – 當設為 true 時,使用者輸入會在半秒的延遲後註冊。DelayOutput – When set to true, user input is registered after half a second delay. 適用於延遲耗費資源的作業,直到使用者完成輸入文字 (也就是當輸入是在其他公式中使用時進行篩選)。Useful for delaying expensive operations until user completes inputting text (i.e. for filtering when input is used in other formulas).

DisplayMode – 控制項允許使用者輸入 (編輯)、只顯示資料 (檢視) 或者已停用 (停用)。DisplayMode – Whether the control allows user input (Edit), only displays data (View), or is disabled (Disabled).

DisabledBorderColor – 控制項的 DisplayMode 屬性設為 Disabled 時,該控制項所呈現的框線色彩。DisabledBorderColor – The color of a control's border if the control's DisplayMode property is set to Disabled.

DisabledColor – 控制項的 DisplayMode 屬性設為 Disabled 時,該控制項所呈現的文字色彩。DisabledColor – The color of text in a control if its DisplayMode property is set to Disabled.

DisabledFill – 控制項的 DisplayMode 屬性設為 Disabled 時,該控制項所呈現的背景色彩。DisabledFill – The background color of a control if its DisplayMode property is set to Disabled.

Fill – 控制項的背景色彩。Fill – The background color of a control.

Font – 文字可使用的字型家族名稱。Font – The name of the family of fonts in which text appears.

FontWeight – 控制項的文字字型粗細︰BoldSemiboldNormalLighterFontWeight – The weight of the text in a control: Bold, Semibold, Normal, or Lighter.

Format – 使用者輸入是否僅限於數字,或可以是任何文字。Format – Whether the user input is restricted to numbers only or can be any text.

Height – 控制項的頂端和底部邊緣之間的距離。Height – The distance between a control's top and bottom edges.

HintText – 如果是空白的,即會在輸入文字控制項顯示淺灰色文字。HintText – Light-grey text that appears in an input-text control if it's empty.

HoverBorderColor – 使用者將滑鼠指標停留在控制項上時,該控制項所呈現的框線色彩。HoverBorderColor – The color of a control's border when the user keeps the mouse pointer on that control.

HoverColor – 使用者將滑鼠指標停留在控制項上時,該控制項所呈現的文字色彩。HoverColor – The color of the text in a control when the user keeps the mouse pointer on it.

HoverFill – 使用者將滑鼠指標停留在控制項上時,該控制項所呈現的背景色彩。HoverFill – The background color of a control when the user keeps the mouse pointer on it.

Italic – 控制項中的文字是否為斜體。Italic – Whether the text in a control is italic.

LineHeight – 兩者之間的距離,例如文字行或清單中項目之間的距離。LineHeight – The distance between, for example, lines of text or items in a list.

MaxLength – 使用者可以輸入到文字輸入控制項中的字元數。MaxLength – The number of characters that the user can type into a text-input control.

Mode – 控制項處於 SingleLineMultiLinePassword 模式。Mode – The control is in SingleLine, MultiLine, or Password mode.

OnChange – 使用者變更控制項的值 (例如,調整滑桿) 時,應用程式的回應方式。OnChange – How the app responds when the user changes the value of a control (for example, by adjusting a slider).

OnSelect – 在使用者點選或按一下控制項時,應用程式的回應方式。OnSelect – How the app responds when the user taps or clicks a control.

PaddingBottom – 控制項中文字與該控制項下邊緣之間的距離。PaddingBottom – The distance between text in a control and the bottom edge of that control.

PaddingLeft – 控制項中文字與該控制項左邊緣之間的距離。PaddingLeft – The distance between text in a control and the left edge of that control.

PaddingRight – 控制項中文字與該控制項右邊緣之間的距離。PaddingRight – The distance between text in a control and the right edge of that control.

PaddingTop – 控制項中文字與該控制項上邊緣之間的距離。PaddingTop – The distance between text in a control and the top edge of that control.

PressedBorderColor – 使用者點選或按一下控制項時,該控制項所呈現的框線色彩。PressedBorderColor – The color of a control's border when the user taps or clicks that control.

PressedColor – 使用者點選或按一下控制項時,該控制項所呈現的文字色彩。PressedColor – The color of text in a control when the user taps or clicks that control.

PressedFill – 使用者點選或按一下控制項時,該控制項所呈現的背景色彩。PressedFill – The background color of a control when the user taps or clicks that control.

RadiusBottomLeft – 控制項左下角的角度 (四捨五入)。RadiusBottomLeft – The degree to which the bottom-left corner of a control is rounded.

RadiusBottomRight – 控制項右下角的角度 (四捨五入)。RadiusBottomRight – The degree to which the bottom-right corner of a control is rounded.

RadiusTopLeft – 控制項左上角的角度 (四捨五入)。RadiusTopLeft – The degree to which the top-left corner of a control is rounded.

RadiusTopRight – 控制項右上角的角度 (四捨五入)。RadiusTopRight – The degree to which the top-right corner of a control is rounded.

Reset – 控制項是否還原為其預設值。Reset – Whether a control reverts to its default value.

Size – 控制項上文字的字型大小。Size – The font size of the text that appears on a control.

Strikethrough – 決定控制項上的文字中間是否有一條線。Strikethrough – Whether a line appears through the text that appears on a control.

TabIndex – 自訂控制項在設定為非零值時於執行階段的定位順序。TabIndex – Customizes the tab order of controls at runtime when set to a non-zero value.

Tooltip – 使用者將滑鼠指標停留在控制項上方時所顯示的說明文字。Tooltip – Explanatory text that appears when the user hovers over a control.

Underline – 決定控制項上的文字底部是否有一條線。Underline – Whether a line appears under the text that appears on a control.

Visible – 控制項顯示或隱藏。Visible – Whether a control appears or is hidden.

Width – 控制項左邊緣與右邊緣之間的距離。Width – The distance between a control's left and right edges.

X – 控制項左邊緣與其父容器 (沒有父容器時則為螢幕) 左邊緣之間的距離。X – The distance between the left edge of a control and the left edge of its parent container (screen if no parent container).

Y – 控制項上邊緣與其父容器 (沒有父容器時則為螢幕) 上邊緣之間的距離。Y – The distance between the top edge of a control and the top edge of the parent container (screen if no parent container).

DateTimeValue( String )DateTimeValue( String )

範例Examples

收集資料Collect data

  1. 新增兩個文字輸入控制項,並將它們命名為 inputFirstinputLastAdd two text-input controls, and name them inputFirst and inputLast.

    不知道如何新增、命名和設定控制項嗎?Don't know how to add, name, and configure a control?

  2. 新增按鈕,將其 Text 屬性設為 Add,並且將其 OnSelect 屬性設為以下公式:Add a button, set its Text property to Add, and set its OnSelect property to this formula:
    收集 (名稱、 {FirstName:inputFirst.Text、 LastName:inputLast.Text})Collect(Names, {FirstName:inputFirst.Text, LastName:inputLast.Text})

    想要了解 Collect 函式或其他函式的詳細資訊嗎?Want more information about the Collect function or other functions?

  3. 以直向/垂直方向新增圖文集庫,將其 Items 屬性設定為 Names,並且將 Subtitle1Text屬性設定為 ThisItem.FirstNameAdd a text gallery in portrait/vertical orientation, set its Items property to Names, and set the Text property of Subtitle1 to ThisItem.FirstName.
  4. (選擇性) 在範本資源庫中,刪除名為 Body1 的底端標籤,並且將資源庫的 TemplateSize 屬性設定為 80(optional) In the template gallery, delete the bottom label, named Body1, and set the TemplateSize property of the gallery to 80.
  5. 按下 F5 鍵,將文字字串輸入至 inputFirstinputLast,然後按一下或點選 [新增] 按鈕。Press F5, type a string of text into inputFirst and inputLast, and then click or tap the Add button.
  6. (選擇性) 將更多名稱新增至集合,然後按下 Esc 鍵以返回預設工作區。(optional) Add more names to the collection, and then press Esc to return to the default workspace.

提示輸入密碼Prompt for a password

  1. 新增文字輸入控制項、將它命名為 inputPassword,並且將其 Mode 屬性設定為 PasswordAdd a text-input control, name it inputPassword, and set its Mode property to Password.
  2. 新增標籤,並將其 Text 屬性設定為下列公式:Add a label, and set its Text property to this formula:
    If(inputPassword.Text = "P@ssw0rd", "Access granted", "Access denied")If(inputPassword.Text = "P@ssw0rd", "Access granted", "Access denied")

    想要了解 If 函式或其他函式的詳細資訊嗎?Want more information about the If function or other functions?

  3. 按下 F5 鍵,然後在 inputPassword中輸入 P@ssw0rdPress F5, and then type P@ssw0rd in inputPassword.

    當您完成輸入密碼時,標籤會停止顯示 [拒絕存取],並且開始顯示 [授與存取權]。When you finish typing the password, the label stops showing Access denied and starts to show Access granted.

  4. 若要返回預設工作區,請按下 Esc 鍵。To return to the default workspace, press Esc.
  5. (選擇性) 新增控制項,例如箭號,設定它以瀏覽至另一個畫面,僅在使用者輸入密碼之後才顯示它。(optional) Add a control such as an arrow, configure it to navigate to another screen, and show it only after the user types the password.
  6. (選擇性) 新增按鈕,設定其 Text 屬性以顯示 [登入],新增計時器,如果使用者輸入錯誤的密碼,提用輸入文字控制項一段特定的時間,然後按一下或點選 [登入] 按鈕。(optional) Add a button, configure its Text property to show Sign in, add a timer, and disable the input-text control for a certain amount of time if the user types the wrong password and then clicks or taps the Sign in button.