如何使用Addrange使用对象填充listview。对象是:
public class Cable : StateObject
{
public int Id { get; set; }
public int CablePropertyId { get; set; }
public int Item { get; set; }
public int TagNo { get; set; }
public string GeneralFormat { get; set; }
public string EndString { get; set; }
public string CableRevision { get; set; }
public string FromBay { get; set; }
public string FromPanel { get; set; }
}谢谢
发布于 2013-10-29 19:45:07
嗯,AddRange是在一个列表上定义的。
你可以这样做:
var list_view = new ListView();
var some_array = new string[] {"1","2", "3", "4"};
var list_of_strings = new List<string>() ;
list_of_strings.AddRange(some_array);
list_view.ItemsSource = list_of_strings;因此,添加范围接受一个IEnumerable。
在任何情况下,上面的例子都有点傻,因为你可以简单地这样做:
list_view.ItemsSource = some_array;避免了对list_of_strings和AddRange的需要。
https://stackoverflow.com/questions/19656718
复制相似问题