There are two types of data changes:
Similarly, the field data link class also has an OnUpdateData event that occurs as the user of the control modifies the contents of the data-aware control. The calendar control has a UpdateData method that becomes the event handler for the OnUpdateData event. UpdateData assigns the changed value in the data-aware control to the field data link.
type TDBCalendar = class(TSampleCalendar); private procedure UpdateData(Sender: TObject); . . . end;
class PACKAGE TDBCalendar : public TSampleCalendar { private: void __fastcall UpdateData(TObject *Sender); };
procedure UpdateData(Sender: TObject); begin FDataLink.Field.AsDateTime := CalendarDate; { set field link to calendar date } end;
void __fastcall TDBCalendar::UpdateData( TObject* Sender) { FDataLink->Field->AsDateTime = CalendarDate; // set field link to calendar date }
constructor TDBCalendar.Create(AOwner: TComponent); begin inherited Create(AOwner); FReadOnly := True; FDataLink := TFieldDataLink.Create; FDataLink.OnDataChange := DataChange; FDataLink.OnUpdateData := UpdateData; end;
__fastcall TDBCalendar::TDBCalendar(TComponent* Owner) : TSampleCalendar(Owner) { FDataLink = new TFieldDataLink(); // this was already here FDataLink->OnDataChange = DataChange; // this was here too FDataLink->OnUpdateData = UpdateData; // assign UpdateData to the OnUpdateData event }
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|