So far, a change within the data-aware control has changed values in the field data link class. The final step in creating a data editing control is to update the dataset with the new value. This should happen after the person changing the value in the data-aware control exits the control by clicking outside the control or pressing the Tab key.
type TDBCalendar = class(TSampleCalendar); private procedure CMExit(var Message: TWMNoParams); message CM_EXIT; . . . end;
class PACKAGE TDBCalendar : public TSampleCalendar { private: void __fastcall CMExit(TWMNoParams Message); BEGIN_MESSAGE_MAP MESSAGE_HANDLER(CM_EXIT, TWMNoParams, CMExit) END_MESSAGE_MAP };
procedure TDBCalendar.CMExit(var Message: TWMNoParams); begin try FDataLink.UpdateRecord; { tell data link to update database } except on Exception do SetFocus; { if it failed, don't let focus leave } end; inherited; end;
void __fastcall TDBCalendar::CMExit(TWMNoParams &Message) { try { FDataLink.UpdateRecord(); // tell data link to update database } catch(...) { SetFocus(); // if it failed, don't let focus leave throw; } }
type TDBCalendar = class(TSampleCalendar); private procedure DoExit; override; . . . end;
class PACKAGE TDBCalendar : public TSampleCalendar { private: DYNAMIC void __fastcall DoExit(void); . . . };
procedure TDBCalendar.CMExit(var Message: TWMNoParams); begin try FDataLink.UpdateRecord; { tell data link to update database } except on Exception do SetFocus; { if it failed, don't let focus leave } end; inherited; { let the inherited method generate an OnExit event } end;
void __fastcall TDBCalendar::DoExit(void) { try { FDataLink.UpdateRecord(); // tell data link to update database } catch(...) { SetFocus(); // if it failed, don't let focus leave throw; } TCustomGrid::DoExit(); // let the inherited method generate an OnExit event }
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|