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 – 此控件是允许用户输入 (Edit)、仅显示数据 (View),还是已禁用 (Disabled)。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 – 控件中文本的粗细:粗体半粗体正常细体FontWeight – 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:
    Collect(Names, {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.