Feeding a custom class to a ListView

Posted on 2010-01-05
Last Modified: 2013-12-17
I have a ListView control where I initially just added ListViewItem whose content was populated from a custom class I wrote, called "IPrintDocument".

Now I would like to feed IPrintDocument instances as DataSource for those ListViewItems, telling the ListView which fields of the IPrintDocument will be displayed in each column; the reason I am doing this, is that when interacting with the ListView I need the original IPrintDocument class to go ahead with the application.

So, is there a way to keep the original class as DataSource of each ListView item?
Question by:Emanuele_Ciriachi
    LVL 13

    Expert Comment

    Just make sure that your custom class implements the IList interface. So for example, you could have your own class owning the data and bind an array of these objects to the control. Databing is a wide subject. There is, among others, an article here :
    LVL 1

    Author Comment

    Thank you, I will give it a shot right now.
    LVL 33

    Accepted Solution

    I'm not sure you can bind a data source to a ListView, you might need to use a DataGridView, or check out this article on creating your own List View control, inheriting from System.Windows.Forms.ListView, which will support data binding:
    LVL 1

    Author Comment


    I found out that your approach is working. I am building my own custom extension of ListView - if it works, the points are yours.
    LVL 1

    Author Closing Comment

    Not so easy to follow, but that is not your fault. Thanks for leading me in the right direction.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now