Skip to content

Instantly share code, notes, and snippets.

@Pasquina
Last active March 25, 2018 21:37
Show Gist options
  • Save Pasquina/3edf6cf751455ab6fc0e2032153685a2 to your computer and use it in GitHub Desktop.
Save Pasquina/3edf6cf751455ab6fc0e2032153685a2 to your computer and use it in GitHub Desktop.
LiveBindings Demo Creating the TListBindSourceAdapter<TBranch> (Alias BranchListBSWrapper)
{ When the Adapter Bind Source for Branches is created, this event handler creates the
necessry BranchListBSWrapper and passes it back to the Bind Source Adapter. }
procedure TMDLBO.absBranchesCreateAdapter(
Sender: TObject;
var ABindSourceAdapter: TBindSourceAdapter);
begin
{ Begin by creating the BranchWrapper and saving it in the current form }
BranchWrapper := BranchListBSWrapper.Create( // create the Branch Wrapper
self, // (a Type Alias for TListBindSourceAdapter<TBranch>)
Corp.CorpBranches, // The Wrapper points to TObjectList<TBranch>
False); // we keep responsibility for ownership
{ Set up the event handlers for the BranchWrapper. This completes the construction of the BranchWrapper }
BranchWrapper.AfterScroll := AfterBranchScroll;
BranchWrapper.AfterDelete := AfterBranchScroll;
BranchWrapper.AfterInsert := AfterBranchScroll;
{ Return the BranchWrapper to the AdapterBindSource }
ABindSourceAdapter := BranchWrapper; // this gives the TAdapterBindSource the ability to display the branch list
end;
@Pasquina
Copy link
Author

Shows how the TListBindSourceAdapter is created and linked to the TAdapterBindSource. Also, this example shows the specification of Event Methods needed to synchronize Employee Lists with the currently selected Branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment