Drag Drop with multiselect - winforms

I've implemented drag-and-drop from a listbox to a treeview with the help of this question. The only thing I haven't figured out yet is how to drag more than one item from the listbox. I've enabled multiselect on the listbox, but when I have multiple items selected and start the drag, it deselects everything except for the item directly under the mouse pointer. Has anyone gotten drag-and-drop to work with multiselect, and if so, how?

You have to keep the ctrl or shift key pressed when you begin the drop, if you let go the listbox goes back to 'begin select' mode again.

I see this as a bug in the framework as the multi-select behaviour is different to the one in Windows Explorer and is not intuitive at all. See my suggestion here.

Related

Extended Selection in WPF Listbox

we need to customise the Extended Selection in WPF ListBox.
What I need to do is be able to Drag and Select Multiple items(Similar to selecting in excel)
Extended selection in Listbox works fine but for that I have to hold the Shiftkey and drag.
Is there a way I can do the multiple selection just by dragging and not holding the shift key down?
Thanks for looking.
Regards
Saurabh Dighade
This looked promising. I haven't tested it though.
http://www.codeproject.com/KB/WPF/MultiSelectListView2.aspx
Also, a similar SO post: Drag-select with ListBox

WPF ListView arrow navigation and keystroke problem

I have a readonly WPF listView and I am having two problem with it
(1) When I load the listView, I set the selecteditem in code behind. It works fine but when I use up/dowm arrow key to navigate through the list, it always jump to the first item at start.
(2) I can't use keystroke to select item
Can anyone give me some idea about how to solve them?
Thanks
Yes, the problem is you need to call Focus() on the list item after selecting it.
But for various reasons it's not as simple as all that.
See Arrow keys don't work after programmatically setting ListView.SelectedItem
...for full details.

Silverlight: Drag multiple rows from a datagrid

I am working on an app where the user needs to be able to drag items from a datagrid onto a button (this then fires some data updates). After some messing around, I have this working quite well. I have used the DataGridDragDropTarget controls from the toolkit for this.
I now need to allow the user drag multiple rows at once. While the datagrid allows me to select multiple rows, the DataGridDragDropTarget will only drag the first of the selections.
It looks like the DataGridDragDropTarget is not built for multiple dragging.
Would be grateful for any help on this one, this is the first time I have posted on SO - and hoping you guys can come through for me.
Thanks all.
It will drag multiple rows for sure. I am sure you are doing same mistake as i did. I believe all your code are fine.
To drag multiple row click on one row press shift or ctrl to select multiple but "Note here: If you release your mouse click here before drag it will forget what are the multiple items it has selected", so just drag without leaving mouse on your last selected item.(So, I think it works that way without doing anything)
However I am also searching for someway to make it work like drag and drop as in desktop. ;-)

How do you display a custom message box from the selectionchanged event of the silverlight datagrid?

I want to display a custom confirmation message box (ChildWindow) when the user selects a row in a DataGrid in Silverlight. The message box simply has 2 buttons, a yes and a no. When the user clicks No, I want to restore the previously selected item in the DataGrid. I have been able to accomplish all of that.
The problem is that when the message box appears and I click NO and I restore the previously selected item, the item that the user tried to select remains in the MouseOver visual state until I move the mouse over some other row.
Is there any known workaround for this unusual behaviour of the DataGrid, or is this perhaps a legitimate bug in the control? I have done my research and I have not found anything as yet.
Any help would be appreciated.
Thanks!
This is classic mouse enter/leave gotcha thats common in many areas of Silverlight and indeed in many other frameworks as well. The assumption is that that mouse in and out events will come in pairs but they don't when a something else hijacks the mouse events.
Thats is what is happening here the DataGridRow is simplisticly tracking mouse over using the standard mouse events. However when you show a child window while it is in the mouse over state not further mouse events go to the row. When you dismiss the childwindow the mouse is already outside the row so it still gets no events.
A possible workaround is to fiddle with the visual state of the row yourself before showing the child window:-
VisualStateManager.GotoState(someRow, "NormalSelected", false);
Not perfect but possible good enough.

ExtJS Drag with Scroll

I have an interface pretty much identical to one located in the ExtJS examples page:
here
However, if you select items in the images panel, and then attempt to drag the scrollbar in any direction, the items are unselected and another drag instance is started. Makes sense on one level, but what if the user is trying to drag a large selection which involves panel scrolling?
Are there any quick fixes to allow me to drag and scroll without losing the drag selection?
Thanks!
Edit: Forgot to mention that this behaviour is reflected in the example listed above.
For those that are interested, I solved this by adding the following to the DataView:
autoHeight:true,
autoWidth:true,
style:'overflow:auto'
and added this to the Panel holding the DataView
autoScroll:true

Resources