【问题标题】:ListViewItem: how to change List datas to ListViewItem?ListViewItem:如何将列表数据更改为 ListViewItem?
【发布时间】:2013-08-12 02:08:40
【问题描述】:

我有 3 个列表(L1、L2、L3),我想在 ListView 上显示它们。但我无法添加或转换,列表数据到 ListViewItem。类似这样的东西

    List<string> for96 = new List<string>();
    List<string> for97 = new List<string>();
    List<string> for98 = new List<string>();
    ListView lv1=new ListView();
    ListViewItem lvitem = new ListViewItem();
    lvitem.Text=for96;
    lvitem.items.add(97);
    lvitem.items.add(98);
    lv1.items.add(lvitem);

【问题讨论】:

    标签: c# list listview listviewitem


    【解决方案1】:

    您可以采取多种路线,但这是一种可能性。

    将三个字符串列表连接在一起,然后将其设置为ListView 的数据源:

    var combinedLists = for96.Union(for97).Union(for98).ToList();
    
    listView.ItemsSource = combinedLists;
    

    【讨论】:

    • 我在 listview 上得到了 3 个列,将它们组合起来没有用..
    猜你喜欢
    • 1970-01-01
    • 2011-09-03
    • 1970-01-01
    • 1970-01-01
    • 2020-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-10
    相关资源
    最近更新 更多