新增清單方塊、下拉式清單或選項按鈕Add a list box, a drop-down list, or radio buttons

PowerApps 包含多重選取和單一選取選項,包括清單方塊、下拉式清單及選項按鈕。PowerApps includes multi-select and single-select options, including a list box, a drop-down list, and radio buttons. 在本主題中,我們會新增這些控制項,並使用 Table 公式來建置清單。In this topic, we add these controls and use a Table formula to build the lists. 在清單中選取項目時,它會更新其他控制項。When an item is selected in the list, it updates other controls.

必要條件Prerequisites

新增清單方塊Add a list box

  1. 在 [插入] 索引標籤上,選取 [控制項],然後選取 [清單方塊]:On the Insert tab, select Controls, and then select List box:

  2. 將 [清單方塊] 控制項重新命名為 MyListBoxRename the List box control to MyListBox:

  3. 將其 Items 屬性設定為下列運算式:Set its Items property to the following expression:
    ["circle","triangle","rectangle"]

    您的設計工具會看起來如下:Your designer looks similar to the following:

  4. 在 [插入] 索引標籤上,選取 [圖示],選取圓形,然後將它移至 [清單方塊] 控制項的下方:On the Insert tab, select Icons, select the circle, and move it under the List box control:

  5. 新增三角形和矩形,然後在 [清單方塊] 控制項的下方,將這些形狀排成一列:Add a triangle and a rectangle, and then arrange the shapes in a row under the List box control:

  6. 將下列形狀的 Visible 屬性設定為下列函數:Set the Visible property of the following shapes to the following functions:

    形狀Shape 將 Visible 函數設定為Set Visible function to
    圓形circle If("circle" in MyListBox.SelectedItems.Value, true)
    三角形triangle If("triangle" in MyListBox.SelectedItems.Value, true)
    矩形rectangle If("rectangle" in MyListBox.SelectedItems.Value, true)
  7. 預覽您所建立的內容 Preview what you've created . 選取 [清單方塊] 控制項中的不同形狀。Select the different shapes in the List box control. 只有您所選取的形狀會顯示。Only the shape or shapes that you select appear. 按下 ESC 鍵或選取 X 以返回您的畫面。Press Esc or select the X to go back to your screen.

在上述步驟中,您使用運算式在 [清單方塊] 控制項中建立了一組項目清單。In these steps, you used an expression to create a list of items in a List box control. 系統會根據您在 [清單方塊] 控制項中選取的項目,顯示不同的形狀。Depending on what you choose in the List box control, different shapes are displayed. 您可以將此套用至商務上的其他元素。You can apply this to other elements within your business. 例如,您可以使用 [清單方塊] 控制項來顯示產品影像、產品描述及其他內容。For example, you can use a List box control to display product images, product descriptions, and so on.

新增選項按鈕Add radio buttons

  1. 在 [常用] 索引標籤上,選取 [新增畫面]。On the Home tab, select New Screen.

  2. 在 [插入] 索引標籤上,選取 [控制項],然後選取 [選項]。On the Insert tab, select Controls, and then select Radio.

  3. 將 [選項] 控制項重新命名為 Choices,然後將它的 Items 屬性設定為下列公式:Rename the Radio control to Choices, and set its Items property to this formula:
    ["red","green","blue"]

    若有需要,請調整控制項的大小以顯示所有選項。If needed, resize the control to show all the options.

  4. 在 [插入] 索引標籤上,選取 [圖示],然後選取圓形。On the Insert tab, select Icons, and then select the circle.

  5. 將圓形的 Fill 屬性設定為下列函數:Set the Fill property of the circle to the following function:
    If(Choices.Selected.Value = "red", RGBA(192, 0, 0, 1), Choices.Selected.Value = "green", RGBA(0, 176, 80, 1), Choices.Selected.Value = "blue", RGBA(0, 32, 96, 1))

    在此公式中,圓形的顏色會根據您所選擇的選項按鈕而產生變化。In this formula, the circle changes its color depending on which radio button you choose.

  6. 將圓形移至 [選項] 控制項的下方,如下列範例所示:Move the circle under the Radio control, as in this example:

  7. 預覽您所建立的內容:Preview what you've created: . 選取不同的選項按鈕以變更圓形的顏色。Select a different radio button to change the color of the circle. 按下 ESC 鍵或選取 X 以返回您的畫面。Press Esc or select the X to go back to your screen.

新增下拉式清單Add a drop-down list

  1. 新增畫面,然後新增 [下拉式清單] 控制項。Add a screen, and then add a Drop down control.

  2. 將控制項重新命名為 DDChoices,然後將它的 Items 屬性設定為下列公式:Rename the control to DDChoices, and set its Items property to this formula:
    ["red","green","blue"]["red","green","blue"]

  3. 新增圓形,將它移至 [下拉式清單] 控制項的下方,然後將圓形的 Fill 屬性設定為下列公式:Add a circle, move it below the Drop down control, and set the circle's Fill property to this formula:
    If(DDChoices.Selected.Value = "red", RGBA(192, 0, 0, 1), DDChoices.Selected.Value = "green", RGBA(0, 176, 80, 1), DDChoices.Selected.Value = "blue", RGBA(0, 32, 96, 1))

  4. 預覽您所建立的內容:Preview what you've created: . 選取不同的選項以變更圓形的顏色。Select the different options to change the color of the circle.