5-Minute-Snack: Connecting with TDataSource to datasets in FireMonkey using FNC

I grew up with the VCL in Delphi. After building user interfaces (or dialogs) with Turbo Pascal for Windows it was a blessing. I intentionally left out the console app interfaces that we had to build before Windows made additional memory a requirement.

When I taught classes at university in 2007 the young students were not able to appreciate the work that a framework like the VCL or .NET Winforms takes off our shoulders. They were already fed up with having to install the IDE and the database server seperately. Times change – and it makes me feel like a fossil, but that is a different story for a different setting…

On the other hand, old habits die hard. Whenever I drop a TDataSet  component on a form or data module, the TDataSource component follows without much afterthought. Connecting any GUI element using that TDataSource  with a few mouse-clicks is known as one of the key pillars why Delphi made RAD so successful.

With FireMonkey the Delphi world had to leave TDataSource  behind. As .NET made Data Binding popular, new frameworks tend to use it instead of the “old-fashioned” TDataSource  approach. Reasons are manifold as Data Binding tends to close the gap between source code and the user-interface even more. Furthermore, there is no need for designated “database user controls”. You can bind any property to any other property. The dataflow of these binds is very flexible. 

Still, the approach is a breaking change that makes migration of VCL Forms Applications to FireMonkey more difficult. Heck, would it be nice to use the good-old TDataSource  approach in FireMonkey. Thankfully, I can once again rely on FNC from TMS Software to come to the rescue.

As introduced in quite a few posts before, FNC offers the means to develop in any framework with the same set of components and deploy the app to any of the supported platforms by Delphi.

So far, it allows using the TDataSource  interface with its grid ( TTMSFNCGrid ) and planner ( TTMSFNCPlanner ) components. The following screenshot shows the setup with TFDMemTable :

DataSource1 is connected to FDMemTable1. The link between the grid and the datasource is handled by the TTMSFNCGridDatabaseAdapter :

You specify the datasource and the grid. If you enable the control using its Active  propery, you can even see the result during runtime. Something that we learned to appreciate. You can also setup the columns during design time in the component. 

You see, there is no difference to the approach you have been used to for years. Furthermore, you can use the exact same setup in the VCL app. FNC controls can be used in VCL and FireMonkey. That is something you might have to get used to at first, but FNC makes multi-platform-multi-framework-development a thing of reality.

Hopefully TMS will provide additional support for the TDataSource interface for other graphical user controls of the FNC component set.

Posted in Delphi

Leave a Reply

Your email address will not be published. Required fields are marked *