PowerApps 中的日期選擇器控制項Date Picker control in PowerApps

使用者可以按一下或點選以指定日期的控制項。A control that the user can click or tap to specify a date.

說明Description

如果您新增日期選擇器控制項,而非文字輸入控制項,則有助於確保使用者指定格式正確的日期。If you add a Date Picker control instead of a Text input control, you help ensure that the user specifies a date in the correct format.

主要屬性Key properties

DefaultDate – 日期控制項的初始值,除非使用者變更。DefaultDate – The initial value of a date control unless the user changes it.

SelectedDate – 日期控制項中目前選取的日期。SelectedDate – The date currently selected in a date control.

Format – 文字格式,控制項會以該格式顯示日期,使用者使用該格式指定日期。Format – The text format in which the control shows the date and the user specifies the date. 您可以將此屬性設定為 ShortDate (預設值) 或 LongDate,根據此控制項的 Language 屬性格式化日期。You can set this property to ShortDate (default) or LongDate to format dates based on the Language property of this control. 如果您想要使用相同的格式,不論語言為何,您也可以將此屬性設定為運算式,例如 yyyy/mm/ddYou can also set this property to an expression, such as yyyy/mm/dd if you want the same format regardless of language. 例如:For example:

  • 如果使用者按一下或點選 2017 年的最後一天,Format 屬性設為 ShortDate,且 Language 屬性設為 en-us,則控制項會顯示 12/31/2017The control shows 12/31/2017 if the user clicks or taps the last day of 2017, the Format property is set to ShortDate, and the Language property is set to en-us.
  • 如果使用者按一下或點選 2017 年的最後一天,Format 屬性設為 LongDate,且 Language 屬性設為 fr-fr,則控制項會顯示 dimanche 31 decembre 2017The control shows dimanche 31 decembre 2017 if the user clicks or taps the last day of 2017, the Format property is set to LongDate, and the Language property is set to fr-fr.

Language – 決定用來格式化日期的語言,包含月份名稱。Language – Determines the language used to format dates, including names of months. 如果未指定此屬性,使用者的裝置設定會決定語言。If this property isn't specified, the user's device setting determines the language.

其他屬性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 – 控制項允許使用者輸入 (編輯)、只顯示資料 (檢視) 或者已停用 (停用)。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.

EndYear – 使用者可以設定日期選擇器控制項值的最新年份。EndYear – The latest year to which the user can set value of a date-picker control.

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.

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

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

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.

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

StartYear – 使用者可以設定日期選擇器控制項值的最早年份。StartYear – The earliest year to which the user can set the value of a date-picker control.

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

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

Year( DateTimeValue )Year( DateTimeValue )

範例Example

  1. 新增日期選擇器控制項,並將它命名為 DeadlineAdd a Date Picker control, and name it Deadline.

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

  2. 新增標籤控制項,並將其 Text 屬性設為以下公式:Add a Label control, and set its Text property to this formula:
    DateDiff(Today(), Deadline.SelectedDate) & " days to go!"DateDiff(Today(), Deadline.SelectedDate) & " days to go!"

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

  3. 按下 F5 鍵,並在 [Deadline] 中選擇日期,然後按一下或點選 [確定]。Press F5, choose a date in Deadline, and then click or tap OK.

    標籤控制項會顯示今天與您所選擇日期之間的天數。The Label control shows the number of days between today and the date that you chose.

  4. 若要返回預設工作區,請按下 Esc 鍵。To return to the default workspace, press Esc.