PowerApps 中的列表框控件List Box control in PowerApps

用户可以选择一个或多个项的列表。A list in which the user can select one or multiple items.

说明Description

列表框控件始终显示所有可用的选项(不同于下拉控件),用户可以一次选择多个项(不同于单选控件)。A List Box control always shows all available choices (unlike a Drop down control) and in which the user can choose more than one item at a time (unlike a Radio control).

关键属性Key properties

Default – 用户更改控件前的初始值。Default – The initial value of a control before it is changed by the user.

Items - 控件中显示的数据源,如库、列表或图表。Items – The source of data that appears in a control such as a gallery, a list, or a chart.

Items The source of data that appears in a control such as a gallery, a list, or a chart.

When you add a gallery, a list, or a chart, the property list shows Items by default so that you can easily specify the data that the new control should show. For example, you might set the Items property of a gallery to the Account table in Salesforce, a table named Inventory that you created in Excel and uploaded to the cloud, or a SharePoint list named ConferenceSpeakers.

其他属性Additional properties

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.

Color – 控件中文本的颜色。Color – The color of text in a control.

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.

Height – 控件上边缘和下边缘之间的距离。Height – The distance between a control's top and bottom edges.

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.

ItemPaddingLeft – 列表框中的文本与其左边缘之间的距离。ItemPaddingLeft – The distance between text in a listbox and its left edge.

LineHeight - 文本行之间或列表中项之间的距离。LineHeight – The distance between, for example, lines of text or items in a list.

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.

Reset - 控件是否还原为其默认值。Reset – Whether a control reverts to its default value.

SelectionColor – 所选项目或列表中项目的文本颜色,或笔控件中选择工具的颜色。SelectionColor – The text color of a selected item or items in a list or the color of the selection tool in a pen control.

SelectionFill – 所选项目、列表中项目或笔控件中选定区域的背景颜色。SelectionFill – The background color of a selected item or items in a list or a selected area of a pen control.

SelectMultiple – 用户是否可以选择列表框中的多个项目。SelectMultiple – Whether a user can select more than one item in a listbox.

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).

Distinct( DataSource, ColumnName )Distinct( DataSource, ColumnName )

示例Example

  1. 添加“列表框”控件,将其命名为“CategoryList”,并将其 Items 属性设置为以下公式:Add a List box control, name it CategoryList, and set its Items property to this formula:
    ["Carpet","Hardwood","Tile"] ["Carpet","Hardwood","Tile"]

    不知道如何添加、命名和配置控件Don't know how to add, name, and configure a control?

    列表框中的地板类别

  2. 添加三个下拉控件,将它们移动到“CategoryList”下,并分别命名为“CarpetList”、“HardwoodList”和“TileList”。Add three Drop down controls, move them under CategoryList, and name them CarpetList, HardwoodList, and TileList.
  3. 将每个下拉控件的 Items 属性设置为以下值之一:Set the Items property of each Drop down control to one of these values:

    • CarpetList:["Caserta Stone Beige","Ageless Beauty Clay", "Lush II Tundra"]CarpetList: ["Caserta Stone Beige","Ageless Beauty Clay", "Lush II Tundra"]
    • HardwoodList:["Golden Teak","Natural Hickory", "Victoria Mahogany"]HardwoodList: ["Golden Teak","Natural Hickory", "Victoria Mahogany"]
    • TileList:["Honey Onyx Marble","Indian Autumn Slate", "Panaria Vitality Ceramic"]TileList: ["Honey Onyx Marble","Indian Autumn Slate", "Panaria Vitality Ceramic"]

      下拉列表中的地板名称

  4. 将每个下拉控件的 Visible 属性设置为以下值之一:Set the Visible property of each Drop down control to one of these values:

    • CarpetList:If("Carpet" in CategoryList.SelectedItems.Value, true)CarpetList: If("Carpet" in CategoryList.SelectedItems.Value, true)
    • HardwoodList:If("Hardwood" in CategoryList.SelectedItems.Value, true)HardwoodList: If("Hardwood" in CategoryList.SelectedItems.Value, true)
    • TileList:If("Tile" in CategoryList.SelectedItems.Value, true)TileList: If("Tile" in CategoryList.SelectedItems.Value, true)

      想要了解有关 If 函数或其他函数的详细信息?Want more information about the If function or other functions?

  5. 按 F5,然后在“CategoryList”中选择一个或多个项。Press F5, and then choose one or more items in CategoryList.

    根据你的选择,将显示相应的一个或多个下拉控件。The appropriate Drop down control or controls appear based on your choice or choices.

    下拉列表中的地板名称

  6. (可选)按 Esc 返回默认工作区。(optional) Press Esc to return to the default workspace.