[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Feeding a custom class to a ListView

Posted on 2010-01-05
Medium Priority
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
  • 3
LVL 13

Expert Comment

ID: 26180548
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 : http://msdn.microsoft.com/en-us/library/ms951295.aspx.

Author Comment

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

Accepted Solution

Todd Gerbert earned 2000 total points
ID: 26180667
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: http://www.codeproject.com/KB/list/ListView_DataBinding.aspx

Author Comment

ID: 26181526

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

Author Closing Comment

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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

834 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