Hello,
there is a strange problem adding some RadContextMenuItems to the context menu from a GridView.
It works fine to catch the ContextMenuOpening event and add the Items (3 Separators and 4 MenuItems in this case) from a RadContextMenu on the form by the following code snippet:
Private Sub DataGridViewMain_ContextMenuOpening(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.ContextMenuOpeningEventArgs) Handles DataGridViewMain.ContextMenuOpening |
Try |
e.ContextMenu.Items.AddRange(RadContextMenuGridView.Items) |
Catch |
End Try |
End Sub |
But sometimes after 3, sometimes after 10 or later tries the AddRange throws an exception:
"Das angegebene Element kann nicht entfernt werden, da es nicht in der Auflistung gefunden wurde."
The context menu shows without the custom added items. The problem is not the contextmenu but the items collection that should be added. It seems that it is blocked by the old context menu instance and not released properly.
I could not workaround this. I have to create a new instance of the form to get it work again.
Is there a fix for this or is it possible to duplicate the Item Collection so that there is no blocking?
Thank you!
Bernd