0

我将从我的代码开始,然后解释问题。

 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 属性时,我收到一条错误消息,指出“要复制的行索引超出范围”,我终生无法找出原因。

请有人指出我正确的方向。

4

1 回答 1

0

好的,所以我现在觉得有点愚蠢。

出于某种原因,我放置了在所选索引更改时将 DataSource 设置为 null 的代码。

是的,我知道,为什么?答案是,我不知道我为什么这样做:P 但删除它,一切都好

于 2013-09-25T22:02:39.677 回答