mail-archives/mono-bugs/2008-September/079222.html

219 строки
5.0 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-bugs] [Bug 425342] New: ListView: Remove Item while enumerating
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%20425342%5D%20New%3A%20ListView%3A%20Remove%20Item%20while%0A%09enumerating&In-Reply-To=">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="079217.html">
<LINK REL="Next" HREF="079241.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-bugs] [Bug 425342] New: ListView: Remove Item while enumerating</H1>
<B>bugzilla_noreply at novell.com</B>
<A HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%20425342%5D%20New%3A%20ListView%3A%20Remove%20Item%20while%0A%09enumerating&In-Reply-To="
TITLE="[Mono-bugs] [Bug 425342] New: ListView: Remove Item while enumerating">bugzilla_noreply at novell.com
</A><BR>
<I>Wed Sep 10 21:27:50 EDT 2008</I>
<P><UL>
<LI>Previous message: <A HREF="079217.html">[Mono-bugs] [Bug 409300] Specified AppDomain configuration file ignored
</A></li>
<LI>Next message: <A HREF="079241.html">[Mono-bugs] [Bug 425342] ListView: Remove Item while enumerating
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#79222">[ date ]</a>
<a href="thread.html#79222">[ thread ]</a>
<a href="subject.html#79222">[ subject ]</a>
<a href="author.html#79222">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE><A HREF="https://bugzilla.novell.com/show_bug.cgi?id=425342">https://bugzilla.novell.com/show_bug.cgi?id=425342</A>
Summary: ListView: Remove Item while enumerating
Product: Mono: Class Libraries
Version: 2.0
Platform: i386
OS/Version: All
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Windows.Forms
AssignedTo: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">mono-bugs at lists.ximian.com</A>
ReportedBy: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">johnm at hlaustralia.com.au</A>
QAContact: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">mono-bugs at lists.ximian.com</A>
Found By: DeveloperNet
Description of Problem:
If you are enumerating through the ListView.Items collection and remove an
item, the next iteration will result in a System.InvalidOperationException
Steps to reproduce the problem:
using System;
using System.Windows.Forms;
public class test
{
static void Main ()
{
Form f = new Form ();
ListView lv = new ListView();
for (int i = 0; i &lt; 20; i++)
{
ListViewItem item = lv.Items.Add(&quot;Item&quot;);
if (i % 2 == 0)
item.Tag = &quot;DELETEME&quot;;
else
item.Tag = String.Empty;
}
foreach (ListViewItem item in lv.Items)
{
if (item.Tag.Equals(&quot;DELETEME&quot;))
{
lv.Items.Remove(item);
}
}
Console.Write(String.Format(&quot;Items = {0}, Expected=10&quot;,
lv.Items.Count));
lv.Parent = f;
Application.Run (f);
}
}
Actual Results:
Exception is raised.
Expected Results:
The Item is Deleted (this works in MS.NET, Visual Studio 2005) and the
iteration takes you to the next item.
How often does this happen?
Every Time.
Additional Information:
--
Configure bugmail: <A HREF="https://bugzilla.novell.com/userprefs.cgi?tab=email">https://bugzilla.novell.com/userprefs.cgi?tab=email</A>
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="079217.html">[Mono-bugs] [Bug 409300] Specified AppDomain configuration file ignored
</A></li>
<LI>Next message: <A HREF="079241.html">[Mono-bugs] [Bug 425342] ListView: Remove Item while enumerating
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#79222">[ date ]</a>
<a href="thread.html#79222">[ thread ]</a>
<a href="subject.html#79222">[ subject ]</a>
<a href="author.html#79222">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.ximian.com/mailman/listinfo/mono-bugs">More information about the mono-bugs
mailing list</a><br>
</body></html>