gurpal2000 0 Posted November 26, 2018 Newbie here. I have used various web toolkits and am familiar with MVC/MVVM. Trying some desktop development. Plenty of examples on the web about binding say TObjectList<TPerson> to a TListView through the use of TPrototypeBindSource or TAdapterBindSource+TDataGeneratorAdapter. All those seem to require prototype fields/data and then binding code to the ObjectList. It seems over the top. Of course I'd rather not iterate over the list and manually set a Caption and SubItem (if I have say FirstName and SecondName as columns). That would be mad. What I want to do is effectively associate the TObjectList with the ListView. Is there a way to do this simpler without the bindsource/adapter just in pure code. Do I need to write a custom adapter? Any examples? Share this post Link to post
David Schwartz 426 Posted November 27, 2018 Do you want to use the TListView just for viewing the contents of the TObjectList? Or do you want to treat it like a DB-aware component that lets you edit what's in the list as well? Those are going to be very different solutions. The former is rather simple; the latter can be quite complex depending on how you want to approach it. Share this post Link to post
gurpal2000 0 Posted November 27, 2018 Hi David, thanks for replying. Editing - by that do you mean inline editing, like textboxes appear inside the row itself and so forth? No. I want to manipulate the view by operating purely on the TObjectList. The UI threads simply update TListView. For example If I change a person's name (in code), I would find the object in the TObjectList, change it. And the component should just reflect it. I'm using VCL by the way if that makes any difference. Maybe I'm expecting too much here 😕 thanks, Share this post Link to post
Markus Kinzler 174 Posted November 27, 2018 Have a look at the MyTunes demo from Grijjy Foundation's MVVM Starterkit. https://github.com/DelphiPraxis/MvvmStarterKit Share this post Link to post
gurpal2000 0 Posted November 27, 2018 Ah very helpful. Will take a look. Thx Share this post Link to post