By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,728 Members | 1,133 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,728 IT Pros & Developers. It's quick & easy.

Listbox woes

P: n/a
I had a listbox that allows reordering of listed items using the mouse
to drag and drop. In the DragDrop event handler, the key instructions
are:

MyListBox..Items.RemoveAt(PreMoveIndex)
MyListBox..Items.Insert(PostMoveIndex, itemtext)

This all works fine.

I then decided that I wanted to display a longer text description of
the currently selected ListBox item in a separate textbox AND have the
description update whenever the currently-selected item in the Listbox
changed.

So I put some code to do this in a MyListBox.SelectedIndexChanged
event handler. Sadly this has broken the feature that allows
reordering of Listbox items with the mouse.

What actually happens is that the item that is selected and picked up
to drag simply disappears from the listbox. I'm guessing that the
RemoveAt instruction gets carried out, but this causes the
SelectedIndexChanged event to fire and execution passes to its own
event handler, never to return.

So a couple of questions please:

1. Is my idea of what's going wrong here likely to be correct?

2. Can anyone suggest a workaround or maybe a different way of
achieving the same end? (Or maybe a pointer to some online resource
that covers this sort of control operation.)

Thanks
JGD
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.