locked
How do I add a DataTable to a ListView? RRS feed

  • Question

  • How do I add a DataTable to a ListView?

    Consider this code:

     public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                addData();
            }
    
            public void addData()
            {        
                DataTable dt = new DataTable();
                dt.Columns.Add("Column 1");
                dt.Columns.Add("Column 2");
                dt.Rows.Add(new object[] { "Dummy", "Data"});
                dataGridView1.DataSource = dt;
            }
        }    

    If I would do the same with a ListView, and add the same data to it, how would I go about to do that?
    "listView1.DataSource" doesn't seem to work.

    Monday, February 29, 2016 3:50 PM

Answers