ListView.Items.Insert() bug?

C

Cat

I used the sample drag and drop source of
http://support.microsoft.com/default.aspx/kb/822483
I set the View to SmallIcons, and AllowDrop to True

But the draggedItem wasn't inserted at the specified position.
Instead, it was always inserted at the last position.
So I set a break point, and examined the Items collection.
It seemed that the order of the Items collection was correct.
I thought that the ListView was acting strange so I need to
make it to redraw all items.

LvSequence.BeginUpdate()
LvSequence.Items.Insert(targetIndex, CType(draggedItem.Clone(),
ListViewItem))
' Remove the original copy of the dragged item.
LvSequence.Items.Remove(draggedItem)
' Temporarily change the view to force the ListView redraw all items
LvSequence.View = View.Details
LvSequence.View = View.SmallIcon
LvSequence.EndUpdate()
Well, this is the workaround I've come with. But why does ListView
act like this?

Windows Vista 64bit
VB.NET 2005
 
E

Eternal Snow

try to use

LvSequence.Refresh()

instead of

LvSequence.View = View.Details
LvSequence.View = View.SmallIcon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top