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

Problem with multi-selection using shift key in listbox

P: n/a
Hi,

I'm attempting to do a drag and drop operation from one listbox to another.
I have my listboxes setup with SelectionMode = MultiExtended so that I can
use the shift key, cntrl key, etc. to make multiple selections.

The problem I am having is that when I use the shift key to select a range
of items, I first click on one item (item gets highlighted), then, holding
down the shift key, I select another item (the range of items gets
highlighted). It appears to select the range as desired, however, when I
click on the 2nd item and keep the left mouse button down and start dragging,
the listbox SelectedItems collection only has the 2nd item as being selected
and not the entire range. When I drop into the other listbox, only the 2nd
item is actually moved, because that is the only one in the selected items
collection.

I don't understand why the entire range of items (that do get highlighted)
are not in the SelectedItems collection. I would imagine this is a bug in
..NET. However, in the mean time, does anybody know how to work around this
problem?

Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
It should be possible...

If you look at this MSDN article, the last section is how to do this. It's
in VB, but should be straight forward to convert.

http://msdn.microsoft.com/library/de...mpDragDrop.asp
"Matt Sawyer" <Ma********@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
Hi,

I'm attempting to do a drag and drop operation from one listbox to
another.
I have my listboxes setup with SelectionMode = MultiExtended so that I can
use the shift key, cntrl key, etc. to make multiple selections.

The problem I am having is that when I use the shift key to select a range
of items, I first click on one item (item gets highlighted), then, holding
down the shift key, I select another item (the range of items gets
highlighted). It appears to select the range as desired, however, when I
click on the 2nd item and keep the left mouse button down and start
dragging,
the listbox SelectedItems collection only has the 2nd item as being
selected
and not the entire range. When I drop into the other listbox, only the
2nd
item is actually moved, because that is the only one in the selected items
collection.

I don't understand why the entire range of items (that do get highlighted)
are not in the SelectedItems collection. I would imagine this is a bug in
.NET. However, in the mean time, does anybody know how to work around
this
problem?

Nov 16 '05 #2

P: n/a
That helped as I found this statement in that article:

"You might wonder why this example uses ListView controls rather than
ListBox controls. There is a good reason: The ListBox control does not
support dragging multiple items. Clicking the list invalidates the multiple
selection."

So, I will try to use a ListView instead of a ListBox and see what happens.
Thanks!

"Dan Bass" wrote:
It should be possible...

If you look at this MSDN article, the last section is how to do this. It's
in VB, but should be straight forward to convert.

http://msdn.microsoft.com/library/de...mpDragDrop.asp
"Matt Sawyer" <Ma********@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
Hi,

I'm attempting to do a drag and drop operation from one listbox to
another.
I have my listboxes setup with SelectionMode = MultiExtended so that I can
use the shift key, cntrl key, etc. to make multiple selections.

The problem I am having is that when I use the shift key to select a range
of items, I first click on one item (item gets highlighted), then, holding
down the shift key, I select another item (the range of items gets
highlighted). It appears to select the range as desired, however, when I
click on the 2nd item and keep the left mouse button down and start
dragging,
the listbox SelectedItems collection only has the 2nd item as being
selected
and not the entire range. When I drop into the other listbox, only the
2nd
item is actually moved, because that is the only one in the selected items
collection.

I don't understand why the entire range of items (that do get highlighted)
are not in the SelectedItems collection. I would imagine this is a bug in
.NET. However, in the mean time, does anybody know how to work around
this
problem?


Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.