Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you bind data to multiple columns in a list view?

I have a datasource that I want to bind to a listview that has multiple columns. How do I bind my datasource to that listview

Here is some pseudo code that doesn't work to help illustrate what I am trying to do:

MyDataTable dt = GetDataSource();
ListView1.DataBindings.Add("Column1.Text", dt, "MyDBCol1");
ListView1.DataBindings.Add("Column2.Text", dt, "MyDBCol2");

-- edit --

Sorry, I forgot to mention it was winforms.

like image 970
wusher Avatar asked Nov 26 '22 22:11

wusher


1 Answers

It seems there is a lacuna in functionality of WinForms ListView control (thought it's possible to databind new WPF ListBox).

This article by Nick Karnik describes how to add databinding capability to custom control inherited from WinForms ListView - Data binding a ListView.

like image 78
Alexander Prokofyev Avatar answered Dec 05 '22 01:12

Alexander Prokofyev