C# 按AddRange填充listview
如何使用Addrange用对象填充listview。目标是:C# 按AddRange填充listview,c#,visual-studio-2010,C#,Visual Studio 2010,如何使用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 GeneralF
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; }
}
谢谢,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;
避免使用字符串列表和添加范围创建ListViewItem数组,并将其添加到listview。
list_view.ItemsSource = some_array;