Bug in ListView.Items.Insert(int,ListViewItem)?
-
I seem to have found a bug in ListView.Items.Insert(int,ListViewItem). Could someone please try reproduce this? Maybe I could get a bug report submitted. (Problem seems to occur on 2.0 and 3.5) Steps to Reproduce: 1. Start a new project 2. Add a ListView with five items in it. 3. Label them 1 to 5 so we can see what happens. 4. Add a Button. 5. Add the following code to Button.Click:
ListViewItem item4 = this.listView1.Items[3]; item4.Remove(); this.listView1.Items.Insert(0, item4);
The items should be arranged like this: 4 - 1 - 2 - 3 - 5 Instead we see this: 1 - 2 - 3 - 5 - 4 Workaround: I have found if we switch to View.Details before doing the remove/insert then everything works fine. Replace the code in Button.Click with this:ListViewItem item4 = this.listView1.Items[3]; View oldView = this.listView1.View; this.listView1.BeginUpdate(); this.listView1.View = View.Details; item4.Remove(); this.listView1.Items.Insert(0, item4); this.listView1.View = oldView; this.listView1.EndUpdate();
-
I seem to have found a bug in ListView.Items.Insert(int,ListViewItem). Could someone please try reproduce this? Maybe I could get a bug report submitted. (Problem seems to occur on 2.0 and 3.5) Steps to Reproduce: 1. Start a new project 2. Add a ListView with five items in it. 3. Label them 1 to 5 so we can see what happens. 4. Add a Button. 5. Add the following code to Button.Click:
ListViewItem item4 = this.listView1.Items[3]; item4.Remove(); this.listView1.Items.Insert(0, item4);
The items should be arranged like this: 4 - 1 - 2 - 3 - 5 Instead we see this: 1 - 2 - 3 - 5 - 4 Workaround: I have found if we switch to View.Details before doing the remove/insert then everything works fine. Replace the code in Button.Click with this:ListViewItem item4 = this.listView1.Items[3]; View oldView = this.listView1.View; this.listView1.BeginUpdate(); this.listView1.View = View.Details; item4.Remove(); this.listView1.Items.Insert(0, item4); this.listView1.View = oldView; this.listView1.EndUpdate();
Does the same thing here:confused:
"An eye for an eye only ends up making the whole world blind"
-
Does the same thing here:confused:
"An eye for an eye only ends up making the whole world blind"
-
that was using .net 2
"An eye for an eye only ends up making the whole world blind"
-
I seem to have found a bug in ListView.Items.Insert(int,ListViewItem). Could someone please try reproduce this? Maybe I could get a bug report submitted. (Problem seems to occur on 2.0 and 3.5) Steps to Reproduce: 1. Start a new project 2. Add a ListView with five items in it. 3. Label them 1 to 5 so we can see what happens. 4. Add a Button. 5. Add the following code to Button.Click:
ListViewItem item4 = this.listView1.Items[3]; item4.Remove(); this.listView1.Items.Insert(0, item4);
The items should be arranged like this: 4 - 1 - 2 - 3 - 5 Instead we see this: 1 - 2 - 3 - 5 - 4 Workaround: I have found if we switch to View.Details before doing the remove/insert then everything works fine. Replace the code in Button.Click with this:ListViewItem item4 = this.listView1.Items[3]; View oldView = this.listView1.View; this.listView1.BeginUpdate(); this.listView1.View = View.Details; item4.Remove(); this.listView1.Items.Insert(0, item4); this.listView1.View = oldView; this.listView1.EndUpdate();
Works, thanks a lot. I am using VS 2010 prof. and had the same problem. Using above code fixed it.