我将从我的代码开始,然后解释问题。
var customerAddresses = new CustDeliveryAddresses();
// Select Columns
customerAddresses.Query.Columns.Add(new Column(CustDeliveryAddress.FIELD_DESCRIPTION));
customerAddresses.Query.Columns.Add(new Column(CustDeliveryAddress.FIELD_POSTCODE));
// Filter by Customer.
customerAddresses.Query.Filters.Add(new Filter(CustDeliveryAddress.FIELD_CUSTOMERDBKEY, customerLookup.Customer.SLCustomerAccount));
// Find
customerAddresses.Find();
var addresses = from CustDeliveryAddress address in customerAddresses
select new
{
address.Description,
address.PostCode
};
//customerDeliveryAddesses.AutoGenerateColumns = false;
customerDeliveryAddesses.DataSource = addresses.ToList();
因此,当将addresses.ToList() 分配给DataGridView (customerDeliveryAddresses) 的DataSource 属性时,我收到一条错误消息,指出“要复制的行索引超出范围”,我终生无法找出原因。
请有人指出我正确的方向。