PowerApps 中的下拉列表控件Drop down control in PowerApps

一个列表,在用户不将其打开的情况下,该表仅显示第一项。A list that shows only the first item unless the user opens it.

说明Description

“下拉列表”控件可以节省屏幕的实际空间,尤其是在列表包含大量选项时。A Drop down control conserves screen real estate, especially when the list contains a large number of choices. 此控件仅占用一行空间,除非用户选择箭头符号来显示更多选项。The control takes up only one line unless the user selects the chevron to reveal more choices.

关键属性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.

Selected - 选定项。Selected – The selected item.

其他属性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.

ChevronBackground - 下拉列表中向下箭头的背景色。ChevronBackground – The color behind the down arrow in a dropdown list.

ChevronFill - 下拉列表中的向下箭头的颜色。ChevronFill – The color of the down arrow in a dropdown list.

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.

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.

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

示例Example

  1. 添加“按钮”控件,并将其 Text 属性设置为显示 CollectAdd a Button control, and set its Text property to show Collect.

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

  2. 将此按钮控件的 OnSelect 属性设置为以下公式:Set the OnSelect property of the Button control to this formula:
    ClearCollect(CityPopulations, {City:"London", Country:"United Kingdom", Population:8615000}, {City:"Berlin", Country:"Germany", Population:3562000}, {City:"Madrid", Country:"Spain", Population:3165000}, {City:"Rome", Country:"Italy", Population:2874000}, {City:"Paris", Country:"France", Population:2273000}, {City:"Hamburg", Country:"Germany", Population:1760000}, {City:"Barcelona", Country:"Spain", Population:1602000}, {City:"Munich", Country:"Germany", Population:1494000}, {City:"Milan", Country:"Italy", Population:1344000})ClearCollect(CityPopulations, {City:"London", Country:"United Kingdom", Population:8615000}, {City:"Berlin", Country:"Germany", Population:3562000}, {City:"Madrid", Country:"Spain", Population:3165000}, {City:"Rome", Country:"Italy", Population:2874000}, {City:"Paris", Country:"France", Population:2273000}, {City:"Hamburg", Country:"Germany", Population:1760000}, {City:"Barcelona", Country:"Spain", Population:1602000}, {City:"Munich", Country:"Germany", Population:1494000}, {City:"Milan", Country:"Italy", Population:1344000})

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

  3. 按 F5,单击或点击“按钮”控件,然后按 Esc。Press F5, click or tap the Button control, and then press Esc.
  4. 添加“下拉列表”控件,将其命名为“国家/地区”,并将其 Items属性设置为以下公式:Add a Drop down control, name it Countries, and set its Items property to this formula:
    Distinct(CityPopulations, Country)Distinct(CityPopulations, Country)
  5. 在垂直方向/纵向添加“文本库”控件,并将其 Items 属性设置为以下公式:Add a Text gallery control in vertical/portrait orientation, and set its Items property to this formula:
    Filter(CityPopulations, Countries.Selected.Value in Country)Filter(CityPopulations, Countries.Selected.Value in Country)
  6. 在“文本库”控件的第一项中,将顶部的“标签”控件的“Text”属性设置为“ThisItem.City”,然后删除底部的“标签”控件。In the first item of the Text gallery control, set the Text property of the upper Label control to ThisItem.City, and delete the bottom Label control.
  7. 将“文本库”控件的 TemplateSize 属性设置为 80Set the TemplateSize property of the Text gallery control to 80.
  8. 按 F5,单击或点击“国家/地区”列表中的箭头符号,然后选择该列表中的一个选项。Press F5, click or tap the chevron in the Countries list, and then choose an option in that list.

    “文本库”控件仅显示选定国家/地区中的城市。The Text gallery control shows only those cities in the country that you chose.