Click here to Skip to main content
13,044,705 members (43,455 online)
Click here to Skip to main content
Add your own
alternative version


26 bookmarked
Posted 5 Mar 2006

Yet another databound ListView (This time for .net2)

, 5 Mar 2006
Rate this:
Please Sign up or sign in to vote.
Inherits from the ListView control and adds the functionality of allowing you to easily add a DataSource using .net2s BindingSource

Sample Image - DBListView.jpg



This control like so many before it, inherits from the ListView control and adds the functionality of allowing you to easily add a DataSource from which the list will be built.

If so many before me have built the same control, why you may ask am I reinventing the wheel?

Good question! And I have an equally good answer.

Because I am the first one to do it in .net2!

And why do I need to make one just for .net2? Won’t the earlier ones still work?

Yes they will and quite well. Just not as good as a true .net2 control will.
You see, Microsoft totally redid the DataBinding in .net 2(which shipped with vs2005). Everything is based around a new (non visual) component call the BindingSource for windows forms based programs and DataBindingScource for web based programs.

While the young and sexy v2 has been getting all the attention. Her older plainer sister Windows Forms has also learned a few new tricks.
This new BindingSource accomplishes a lot of cool things. But the best in my opinion is how much it hides what the data source is. To the control there is no difference whether the data is coming from a database through a DataSet, from a WebService through a custom class or from an operating system function in the form of an array of COM classes.

So creating a ListView that works off of the BindingSource is a major accomplishment. It was also extremely easy; the entire project is less than 4k! And a great opportunity for everyone to see what it takes to create a control for the new BindingSource.

The control is bare bones and I will be updating it shortly.

When I am done I will post another article explaining the interesting points of development.

In the mean time I am only posting a short article on how to use it.


Anyone who does database front ends in windows with .net will find this indispensable.

Using it couldn’t be easier! Take a look at the demo!

Anyone who knows the basics of C# or will find it a sinch.

Using the code 

Its quite easy. To use the control you need to add it to your form as you would any other control.

That is you either add it in code. Or if you add the project containing it to your solution it will showup right in your toolbox and then you can just drag it onto the form.

Once the control exists its just a mater of creating a BindingSource with your data (of almost any kind) as its DataSource and then assign it to the controls DataSource!

This can be done either by creating the binding source in code such as

DBListView1.DataSource = new BindingSource(MyData,"");

Or graphically by adding a BindingSource to your form and choosing it as the DataSource for your control in the property inspector.

And then if you need to, you can change the data in the DataSource of the BindingSource as I do in the demo project.

bindingSource1.DataSource = new System.Drawing.Text.InstalledFontCollection().Families;

Have Fun!


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Rabb Moshe Plotkin
United States United States
Co-director of Chabad Student Center @ SUNY New Paltz
Lecturer of Computer Science @ SUNY New Paltz

You may also be interested in...

Comments and Discussions

GeneralMy vote of 1 Pin
adamvsmith14-Jun-10 8:01
memberadamvsmith14-Jun-10 8:01 
GeneralGood suff - here's a trick to make it a bit better! Pin
mutantdna29-Apr-10 17:48
membermutantdna29-Apr-10 17:48 
GeneralRe: Good suff - here's a trick to make it a bit better! Pin
Moshe Plotkin30-Apr-10 2:18
memberMoshe Plotkin30-Apr-10 2:18 
GeneralRe: Good suff - here's a trick to make it a bit better! Pin
mutantdna4-May-10 7:36
membermutantdna4-May-10 7:36 
Generalorder Pin
durbich12-Apr-10 4:26
memberdurbich12-Apr-10 4:26 
Generalorder problem Pin
durbich12-Apr-10 4:25
memberdurbich12-Apr-10 4:25 
GeneralRe: order problem Pin
Moshe Plotkin30-Apr-10 2:17
memberMoshe Plotkin30-Apr-10 2:17 
GeneralYou forgot to unsubscribe to the old data source event handler ! Pin
lcalabrese9-Dec-08 18:54
memberlcalabrese9-Dec-08 18:54 
QuestionBind Columns? Pin
mcgrath13-Jun-07 10:03
membermcgrath13-Jun-07 10:03 
AnswerRe: Bind Columns? Pin
Boinst20-Sep-07 20:45
memberBoinst20-Sep-07 20:45 
GeneralExcellent! Kol Hakavod! Pin
Simmy78-Jun-06 21:59
memberSimmy78-Jun-06 21:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170713.1 | Last Updated 5 Mar 2006
Article Copyright 2006 by Rabb Moshe Plotkin
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid