我开始使用我的代码,然后解释问题。
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();
因此,当address.ToList()被分配给DataGridView(customerDeliveryAddresses)的DataSource属性时,我得到一个错误,指出“要复制的行的索引超出范围”,我不知道在我的生活中找出原因
请有人指出我正确的方向。
答案 0 :(得分:0)
出于某种原因,我已经把代码设置为当所选索引发生变化时将DataSource设置为null。
是的,我知道,为什么?答案是,我不知道为什么我这样做:P但删除它,一切都很好