Heike Posted October 23, 2002 Posted October 23, 2002 I have an ArrayList containing all selected TreeNodes in my TreeView. Now I want to delete them. How? I thought just using For Each DummyNode In alNodes Me.treDokumente.Nodes.Remove(DummyNode) Next would do it, but it doesn't. The first node is removed and then the error is something like "collection was modified; enumeration operation may not execute". Even after a alNodes.Reverse before doing it, the same error occured. Any suggestions?! Quote
*Gurus* divil Posted October 23, 2002 *Gurus* Posted October 23, 2002 Since you're enumerating your own collection not the actual nodes in the treeview, I'm wondering why this is happening. Have you tried using the Remove method of the nodes instead? For Each DummyNode In alNodes DummyNode.Remove() Next Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Heike Posted October 23, 2002 Author Posted October 23, 2002 Thanks, but that doesn't work either. I'm enumerationg my own collection because I had to create my own type because the base TreeView does not support multiple selection. Quote
*Gurus* Derek Stone Posted October 23, 2002 *Gurus* Posted October 23, 2002 Try implementing a IEnumerator interface instead. Dim ieNodes As System.Collections.IEnumerator = alNodes.GetEnumerator While ieNodes.MoveNext 'Remove End While Quote Posting Guidelines
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.