This is a migrated thread and some comments may be shown as answers.

Disable Drop Depending on Data Properties

4 Answers 101 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
heavywoody
Top achievements
Rank 1
heavywoody asked on 13 Jul 2013, 04:05 AM
I have a databound listbox that is bound to a class call Animal.   On another form is several databound listboxes that are different types of animals.  All listboxes use the Animal class.   So what I want to do is when a user grabs an Animal class from the source listbox and drags it over to the form, depending on Animal.Type, only the listbox named the Animal.Type can accept the drop.

I thought maybe I could do this by using DragEnter.  But I can't seem to get the business object out of the data object.  I thought if I could, I could check it, and if it matched the Listbox name, I would enable drop.  If not, I would disable drop on that listbox.  I would do that to all of them.

Is this possible? I have been wrecking my brains and cannot figure out how to get the data out and what property to put it in.  All the examples seem to talk about drag/drop strings.  I have full blown bound objects.

So it is conditionally dropping depending on a property of the object being dragged.

4 Answers, 1 is accepted

Sort by
0
heavywoody
Top achievements
Rank 1
answered on 05 Sep 2013, 09:37 PM
Anyone?  How do I get the object(s) that are being dragged?  Because I have to know a property of the object being dragged to set the drop behavior.
0
Nick
Telerik team
answered on 06 Sep 2013, 01:44 PM
Hi ,

You can do that by using the DragDropPayloadManager(Both to set the data and extract it). You can then use the DragEffects to make the Drop impossible (Efects = None).

Hope this helps!  

Regards,
Nik
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
heavywoody
Top achievements
Rank 1
answered on 07 Sep 2013, 11:57 PM
Ok, one other question.  This works fine.  But I have the condition that if the user holds down the CTRL key while they drag/drop, the logic I talked about overruled and they can drop it on anything.  But I can't seem to capture the CTRL with drag/drop at the same time.  How would you suggest I do that do the drag/drop events know the the CTRL key is held down?
0
Nick
Telerik team
answered on 11 Sep 2013, 11:21 AM
Hi ,

You can handle the Keyboard key down events, and check if the key is Ctrl, to raise a boolean flag indicating the state of the button. You should subscribe tot he event with HandledEventsToo set to true, since something may be handling them in the process. 

Hope this helps! 

Regards,
Nik
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
DragAndDrop
Asked by
heavywoody
Top achievements
Rank 1
Answers by
heavywoody
Top achievements
Rank 1
Nick
Telerik team
Share this question
or