Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Making Win10 Calendar controls database-aware

the future of starts demands massive productivity

Author: Dmitry Kovalenko

Programming is fun. Sometimes projects and apps are more serious, sometimes less. On my recent Delphi 10.1 Update 2 presentation two times I have been asked about data-aware versions of new VCL Win10 calendar controls. Here is the code.

[crayon-672a8d2eae438501466408/]

One of the best things about Delphi is that it comes with the source code. After a lot of googling for examples of custom database aware Delphi components, the actual source code of “TDBText” component in “VCL.DBCtrls” unit was the best resource.

The most important part of a custom data-aware field component is private “TFieldDataLink”. It does all the job, but as component implementer you need to expose its “DataSource” and “FieldName” properties. In the constructor there is also “OnDataChanged” event connected to “DataChanged” procedure. In this way the calendar control knows when it needs to refresh itself. This is centralized in the “GetFieldDate” method that reads the date from the internal “FDataLink.Field”.

Not a rocket science:-)

The source code of custom Win10 VCL data-aware components can be downloaded from this link.

The test application of data-aware “TCalendarView” and “TCalendarPicker” looks like this and is using RAD Studio InterBase “EMPLOYEE” database.

Let’s take a look at how you can create WinAPI Calendar in this article about RAD Studio 10.2.

Exit mobile version