FMX.DatePicker Sample
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.
Contents
Location
You can find the DatePicker sample project at:
- Start | Programs | Embarcadero RAD Studio Athens | 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
- Navigate to one of the locations given above and open:
- Delphi: DatePicker.dproj.
- C++: DatePicker.cbproj.
- Select the target platform, iOS and Android supported.
- Press F9 or choose Run > Run.
- Interact with the sample:
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:
- A TListBox object containing two TListBoxItems.
- The first TListBoxItem contains a TDateEdit object.
- A ToolBar object with a TLabel object.
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
- Mobile Tutorial: Using a Calendar Component to Pick a Date (iOS and Android)
- Tracking the Date
- FMX.DateTimeCtrls.TDateEdit
- System.SysUtils.FormatDateTime