FMX.DatePicker Sample

From RAD Studio Code Examples
Jump to: navigation, search

This sample demonstrates how to use the TDateEdit component to invoke the native date picker at runtime and select a date in order to use it in your own application.

Location

You can find the DatePicker sample project at:

  • Start | Programs | Embarcadero RAD Studio Alexandria | Samples and then navigate to:
    • Object Pascal\Mobile Snippets\DatePicker
    • CPP\Mobile Snippets\DatePicker
  • Subversion Repository:
    • You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.

Description

The DatePicker sample demonstrates how to use the date picker on Android and iOS applications. The sample uses the TDateEdit component that allows you to select a date from the date picker.

How to Use the Sample

  1. Navigate to one of the locations given above and open:
    • Delphi: DatePicker.dproj.
    • C++: DatePicker.cbproj.
  2. Select the target platform, iOS and Android supported.
  3. Press F9 or choose Run > Run.
  4. Interact with the sample:
    • Click or tap the TDateEdit control. See how it displays a date picker that allows you to select a date.
    • Select a date.
    • The picked date is displayed with the following format string: 'dddd, mmmm d, yyyy'.
      Note: Click here to see the meaning of the specifiers of the date time format string.

Files

File in Delphi File in C++ Contains

DatePicker.dproj

DatePicker.cbproj

The project itself.

uMain.fmx

uMain.fmx

The main form where the components are located.

uMain.pas

DatePickerPCH.h, DatePicker.cpp

Used to define and implement the sample.

Information.txt

Information.txt

Further information about the sample.

Classes

TDatePickerForm is the main form that represents the main window of the sample. It contains the following components:

Implementation

  • The sample uses TDateEdit to display a date picker that allows you to select a date.
  • The sample uses TListBox to display the date picker on the first TListBoxItem and to show the selected date on the second TListBoxItem.

When you run the application and click on Pick a Date, the TDateEdit component displays a date picker that allows you to select a date. When you select a date, this date is displayed in a TListBoxItem with a specified date time format.

Uses

See Also

Samples