Cross platform DateEdit demo

Do you need an easy way to keep your DateEdit control up-to-date? Then you need the Update DateEdit Demo! This cross-platform application makes it a breeze to update your DateEdit control through an in-memory data table, regardless of which operating system you’re using. And because it’s built in Delphi, you can be sure that the code is clean and reliable. So why wait? Get the Update DateEdit Demo today!

Download the full cross-platform DateEdit data binding source code on Github.

This demo is part of over 100 cross-platform demos with everything from camera demos to emoji demos and painting demos.

What is a DateEdit control in software development?

A date edit control is a software development tool that allows you to input, edit and format date information. It is typically used in applications where date data needs to be entered or displayed, such as calendars, scheduling tools and email clients. Date edit controls usually have a variety of features that make date entry and management easy, such as the ability to add or subtract days, weeks, months or years. Some date edit controls also allow you to set date ranges or specify date formats. In general, date edit controls can greatly simplify the process of inputting and manipulating date data.

Screenshot

What does the source code look like?

unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
  FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Param,
  FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf,
  FireDAC.Stan.StorageBin, Data.Bind.EngExt, Fmx.Bind.DBEngExt, System.Rtti,
  System.Bindings.Outputs, Fmx.Bind.Editors, Data.Bind.Components,
  FMX.DateTimeCtrls, Data.Bind.DBScope, Data.DB, FireDAC.Comp.DataSet,
  FireDAC.Comp.Client, FMX.Edit, FMX.StdCtrls, FMX.Effects,
  FMX.Controls.Presentation;

type
  TForm1 = class(TForm)
    MaterialOxfordBlueSB: TStyleBook;
    ToolBar1: TToolBar;
    ShadowEffect4: TShadowEffect;
    Label1: TLabel;
    Label2: TLabel;
    BehindEdit1: TEdit;
    FDMemTable1: TFDMemTable;
    BindSourceDB1: TBindSourceDB;
    BindingsList1: TBindingsList;
    LinkPropertyToFieldText: TLinkPropertyToField;
    DateEdit1: TDateEdit;
    LinkControlToField1: TLinkControlToField;
    procedure DateEdit1Change(Sender: TObject);
    procedure BehindEdit1Validate(Sender: TObject; var Text: string);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.DateEdit1Change(Sender: TObject);
begin
  BehindEdit1.Text := DateEdit1.Text;
  TLinkObservers.ControlChanged(BehindEdit1);
end;


procedure TForm1.BehindEdit1Validate(Sender: TObject; var Text: string);
var
  LValue: TDateTime;
begin
  LValue := StrToDateTime(Text);
  if LValue<>DateEdit1.DateTime then
    DateEdit1.DateTime := StrToDateTime(Text);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  BehindEdit1.Text := DateTimeToStr(Now);
end;

end.

What does the data bindings look like?

What does the Form object code look like?

  object BindSourceDB1: TBindSourceDB
    DataSet = FDMemTable1
    ScopeMappings = <>
    Left = 144
    Top = 224
  end
  object BindingsList1: TBindingsList
    Methods = <>
    OutputConverters = <>
    Left = 20
    Top = 5
    object LinkPropertyToFieldText: TLinkPropertyToField
      Category = 'Quick Bindings'
      DataSource = BindSourceDB1
      FieldName = 'Value'
      Component = Label2
      ComponentProperty = 'Text'
    end
    object LinkControlToField1: TLinkControlToField
      Category = 'Quick Bindings'
      DataSource = BindSourceDB1
      FieldName = 'Value'
      Control = BehindEdit1
      Track = False
    end
  end

Ready to learn how to program cross-platform apps like this?

Sign up for the Coding Boot Camp 2022 to learn to program. Topics include: Games, JavaScript, Web, Python, SQL, Databases, iOS, MacOS, Android, Mobile, Linux, Windows, Desktop, Server, and Arduino.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free TrialUpgrade Today

Free Delphi Community EditionFree C++Builder Community Edition