是否可以将List绑定到WinForms中的ListView?

我想将ListView绑定到List 。 我正在使用此代码:

 somelistview.DataBindings.Add ("Items", someclass, "SomeList"); 

我收到此exception: 无法绑定到属性’Items’,因为它是只读的。

如果Items属性是readonly,我不知道如何绑定?

ListView类不支持设计时绑定。 该项目提供了另一种选择。

或者,如果要进行数据绑定,可以使用DataGridView。 当新项目添加到列表中时,使用BindingList和BindingSource将更新DataGrid。

 var barcodeContract = new BarcodeContract { Barcode = barcodeTxt.Text, Currency = currencyTxt.Text, Price = priceTxt.Text }; list.Add(barcodeContract); var bindingList = new BindingList(list); var source = new BindingSource(bindingList, null); dataGrid.DataSource = source; 

和数据模型类

  public class BarcodeContract { public string Barcode { get; set; } public string Price { get; set; } public string Currency { get; set; } }