TDateEdit cannot LiveBinding with a datasource bidirection

158 Views Asked by At

This is a simple question. Start a multidevice App, place a TDateEdit and DBTable with a field containing TdateTime data. Then use LiveBinding designer link the data source field to TDateEdit.DateTime property. However, this link is unidirectional , The control DateEdit can accept the data from the Datasource, but cannot update the changes to the datasource. How to change the link to bidreiction???

enter image description here

2

There are 2 best solutions below

2
Rob Lambden On

There may be some things that are not clearly understood.

Normally a LiveBindings link will be bidirectional - so if you setup two TDateEdits and bind them together changing one should change the other, irrespective of which one you change.

It seems that what you are hoping is that changing the TField will update the data in the database table.

That's not typically how the Data Access components in Delphi work.

The TField is part of a TDataSet. The TDataSet has a Post method to write changes to the underlying data store, if that's supported.

The Data Access components are extremely powerrful and can cope with lots of different scenarios, and allow you to extended capabilities throguh exposed events as well as subclassing the components.

If you want to update your underlying data store you need to have a writeable TDataSet and you need to call Post on it to write.

I suggest you start off with some of the videos in Enbarcadero's YouTube channel about how to use the data acecss components. It's not difficult to do but beyond the scope of an answer here.

0
David Cornelius On

If you use the LiveBindings Wizard to hook the DateEdit with a field, it will hook it up bi-diretionally to a "virtual" SelectedDateTime property of the DateEdit. That property doesn't really exist in the TDateEdit but is used by the LiveBindings to map the separate Date and Time properties of the DateEdit.