Jump to content
gurpal2000

Binding TObjectList to TListView

Recommended Posts

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

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×