Listview / databinding

  • Thread starter Thread starter Paddy
  • Start date Start date
P

Paddy

In the case of a listView, how would the lines below have to be altered?

Thanks,
Paddy

private void MainForm_Load(object sender, System.EventArgs e)
{
City [ ] cityChoices = {new City("Cardiff", "Wales"), new
City("Farnborough","UK")};
listBox1.DataSource = cityChoices;
}
 
Hi Paddy,

I think you may have to do it manually

foreach(City c in cityChoices)
{
ListViewItem l = new ListViewItem(c.Name);
l.SubItems.Add(c.Place);
listView1.Items.Add(l);
}


Happy coding!
Morten Wennevik [C# MVP]
 
Hi Morten,

I have no problems filling a listview with columns and data.

I would like to find out how to use DataSource
with a listView. (Maybe it cannort be done?)

Paddy.
 
Back
Top