BindingList vs. List

J

jwilson128

I am trying to decide whether to use a
system.ComponentModel.BindingList(of T) or a
Sytem.Collections.Generic.List(of T) for a custom collection. In
testing a simple, read-only data binding to a data grid view - they
both work. Are there aspects of databinding that the regular list will
not support and vice-versa, is there any reason to choose a regular
list over the bindinglist? -Jeff
 
R

RobinS

The bindinglist implements the IBindingList interface, so it has a bunch of
properties, methods, events, etc., that you can use. If you don't need
them, a generic list(Of T) will work fine.

For example, I use business objects, and I create BindingList(Of Customer)
to bind to a datagridview so I can capture the update events.

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
 
J

jwilson128

The bindinglist implements the IBindingList interface, so it has a bunch of
properties, methods, events, etc., that you can use. If you don't need
them, a generic list(Of T) will work fine.

For example, I use business objects, and I create BindingList(Of Customer)
to bind to a datagridview so I can capture the update events.

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.





- Show quoted text -

So I'm not giving anything up by using the bindinglist as opposed to
the regular list?
 
R

RobinS

jwilson128 said:
So I'm not giving anything up by using the bindinglist as opposed to
the regular list?

I think a BindingList is kind of like a regular list on steroids. ;-)

The performance might not be as good, but I doubt it would be noticeable.

Robin S.
 
J

jwilson128

I'm not sure I understand - please let me attempt to clarify:

I have a custom business object call Loan. I then want to implement a
custom collection of Loan objects where i can further define business
logic that relates to the collection. Knowing that i will want to bind
the collection of Loans to a form datagrid, should I implement my
custom collection (and relating business logic) using a BindingList as
opposed to a generic List? If this line of thinking is off, I'd love
to understand why? Thanks. -Jeff
 
R

RobinS

Yes, you should use a BindingList(Of Loan). Define your class like this:

Public Class LoanList
Inherits BindingList(Of Loan)

End Class

If you want to figure out how to do upgrades to a DataGridView bound to
your LoanList, check out Brian Noyes' Data Binding book. You can post
back, and if I can figure out how to condense it, I'll post it.

Robin S.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top