I fix the problematic code with some changes. This problem often occurs in control collections. I was puzzled by it when trying to remove nodes from a TreeView control.
List<TreeNode> treeList = new List<TreeNode>();
foreach (TreeNode treeNode in treeViewFolderMove.Nodes)
{
treeList.Add(treeNode);
}
foreach (TreeNode treeNode in treeList)
{
if (treeNode.Value == Value)
{
this.treeViewFolderMove.Nodes.Remove(treeNode);
}
}