locked
Fill listview column with value RRS feed

  • Question

  • I have a listview as below , want to fill the - value with datasource value, how can i fill it in specific values , columns may increase in no

    A    | B     | C

    AA    -         -

    BB    -         -

    CC    -         --

    Regards

    Sufian


    Mohd Sufian www.sqlship.wordpress.com Please mark the post as Answered if it helped.

    • Moved by CoolDadTx Monday, August 31, 2015 4:22 PM Winforms related
    Monday, August 31, 2015 12:52 PM

Answers

  • Are you just asking about how to create the subitems?

    Loosely, it goes like this:

    ListViewItem lvi = new ListViewItem(row["col1"].ToString());
    lvi.SubItems.Add(row["col2"].ToString());
    lvi.SubItems.Add(row["col3"].ToString());
    // etc.
    listView1.Items.Add(lvi);
    

    • Marked as answer by Youjun Tang Monday, September 7, 2015 1:47 AM
    Monday, August 31, 2015 5:53 PM
  • If the values are coming from a Dataset, you might want to consider a DataGridView for displaying them rather than a ListView.
    • Proposed as answer by Youjun Tang Monday, September 7, 2015 1:47 AM
    • Marked as answer by Youjun Tang Monday, September 7, 2015 1:47 AM
    Monday, August 31, 2015 6:28 PM

All replies

  • Are you just asking about how to create the subitems?

    Loosely, it goes like this:

    ListViewItem lvi = new ListViewItem(row["col1"].ToString());
    lvi.SubItems.Add(row["col2"].ToString());
    lvi.SubItems.Add(row["col3"].ToString());
    // etc.
    listView1.Items.Add(lvi);
    

    • Marked as answer by Youjun Tang Monday, September 7, 2015 1:47 AM
    Monday, August 31, 2015 5:53 PM
  • If the values are coming from a Dataset, you might want to consider a DataGridView for displaying them rather than a ListView.
    • Proposed as answer by Youjun Tang Monday, September 7, 2015 1:47 AM
    • Marked as answer by Youjun Tang Monday, September 7, 2015 1:47 AM
    Monday, August 31, 2015 6:28 PM