LoadLayout throws error Collection was modified; enumeration operation may not execute

2 posts, 0 answers
  1. Grant Fish
    Grant Fish avatar
    10 posts
    Member since:
    Apr 2010

    Posted 16 May 2011 Link to this post

    The LoadLayout method of the RadGridView will sometimes throw an error "Collection was modified; enumeration operation may not execute." We have found that this happens after the following sequence of events:

    1. Define one or more filters in the grid.
    2. Use SaveLayout to save the layout definition, which includes the filters.
    3. Use LoadLayout to load the layout that includes filters.
    2. Use LoadLayout to load a different layout that includes no filters.

    Apparently some internal code is iterating through the filter descriptors and attempting to delete them within the iteration. The workaround that we found is to first execute a .Columns.Clear() to remove all of the existing columns. Since they are all going to be replaced by the new layout this produces the same end result, minus the error.

    We believe that this problem was introduced sometime between 2010Q1 and 2011Q1. Upgrading from 2010Q1 to 2011Q1 has been one of the most frustrating and time consuming version changes that I have ever experienced. There are a lot of new features and a lot of fixes, but it seems that little thought was given to backward compatibility.
  2. Jack
    Jack avatar
    2335 posts

    Posted 19 May 2011 Link to this post

    Hello Grant Fish,

    Thank you for contacting us.

    I tested the described scenario and was not able to observe an issue. Please, could you send me your application. This will allow me to investigate the issue further and to find a proper solution. Thank you in advance.

    I am looking forward to your reply.
    Best wishes,
    the Telerik team
    Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
  3. DevCraft banner
Back to Top