Completed
Last Updated: 13 Nov 2015 15:17 by ADMIN
ADMIN
Stefan
Created on: 18 Jul 2013 07:51
Category: GridView
Type: Bug Report
2
FIX. RadGridView - error (Collection was modified; enumeration operation may not execute.) when loading layout
To reproduce:  Dim dockmem As New MemoryStream
    Dim gridmem As New MemoryStream

    Public Sub SetData()

        ' dgvSelectList.DataSource = Nothing
        Dim dt As DataTable
        dt = New DataTable

        dt.Columns.Add("VENDCODE")
        dt.Columns.Add("VENDNAME")
        dt.Rows.Add("AA2", "Arthur")
        dt.Rows.Add("AA2", "Arthur")

        dgvSelectList.DataSource = dt
        dgvSelectList.BestFitColumns()
    End Sub

    Private Sub frmSelectListNG2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        SetData()
        dgvSelectList.EnableFiltering = False
        'Save Grid and Dock layout settings to mem stream and simulate my process
        SaveSettings()
    End Sub

    Public Sub btnGO_Click(sender As System.Object, e As System.EventArgs) Handles btnGO.Click
        LoadSettings()
        dgvSelectList.SplitMode = RadGridViewSplitMode.Horizontal
        SetData()
        LoadSettings()
    End Sub

    Private Sub LoadSettings()
        gridmem.Position = 0
        dockmem.Position = 0
        dgvSelectList.LoadLayout(gridmem)
        rdkSelect.LoadFromXml(dockmem)
    End Sub

    Private Sub SaveSettings()
        gridmem.Position = 0
        dockmem.Position = 0
        dgvSelectList.SaveLayout(gridmem)
        rdkSelect.SaveToXml(dockmem)
    End Sub

Workaround - set the datasource to Nothing prior rebinding
0 comments