Skip to content

Instantly share code, notes, and snippets.

@Pasquina
Created March 25, 2018 20:47
Show Gist options
  • Save Pasquina/12a28f03765a856e4bbc2c6aa89dd369 to your computer and use it in GitHub Desktop.
Save Pasquina/12a28f03765a856e4bbc2c6aa89dd369 to your computer and use it in GitHub Desktop.
LiveBindings Demo AfterScroll Event Handler
{ When the Branch list changes, either because of a scroll, or add or delete, this routine adjusts the
Employee list to display the appropriate employees }
procedure TMDLBO.AfterBranchScroll(ABindSourceAdapter: TBindSourceAdapter);
var
LBranch: TBranch; // currently displayed Branch
begin
{ A series of casts extracts the current TBranch object being displayed }
LBranch := TBranch(TListBindSourceAdapter(ABindSourceAdapter).Current); // obtain the current TBranch object
if Assigned(LBranch) then // might be an empty list if all entries have been deleted
begin
EmployeeWrapper.SetList( // change the Employee Wrapper to point to
LBranch.BranchEmployees, // the TObjectList<TEmployee> in the currently
False); // displayed Branch
EmployeeWrapper.First; // position to the first Employee
EmployeeWrapper.Active := True; // this will populate the list and make it visible
end
else
begin
EmployeeWrapper.SetList( // If there is no current branch
nil, // there can be no current employees
False);
end;
end;
@Pasquina
Copy link
Author

Shows the event handler code needed to update the child ListView display when the focus of the parent ListView changes ListItems.

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