1

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

Haizhou
  • 127
  • 7

2 Answers2

0

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.

Rob Lambden
  • 2,175
  • 6
  • 15
  • Thanks for your comment. the diagram of the livebinding desiner shows it more clearly. As you can see the link line between the datasource and the DateEdit3 only has one arrow at the control end. The line between Comboedit4 and the the datasource has two arrows at both ends. At rumtime, the datasource changes can reflect at the DateEdit3 on windows platform, but the changes (e.g.changing date) won't trigger OnDataCHange event on BindSourceDB3.SubDataSource. So I cannot do anything from there. But for other controls with two arrows, that event can be triggered. – Haizhou Mar 22 '21 at 22:59
  • What are the specifications of the fields in the database? Sepcifically EventType (showing two arrows) and TargetTime (showing one arrow). You also appear to have multiple items linking to the TargetTime field, that shouldn't make a difference as far as I know, but you may want to identify the smallest, simplest instance to identify it working. – Rob Lambden Mar 23 '21 at 00:21
0

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.

David Cornelius
  • 437
  • 1
  • 5
  • 12