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

Drop Highlight

3 Answers 63 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Kim
Top achievements
Rank 1
Kim asked on 15 Sep 2010, 08:32 AM

Hi, I am trying to get the RadDragDrop manager working as i need and I am getting close.

However, I have a grid that contains a usercontrol in each cell (similar to a calender). When the mouse moves over a cell i change the backcolor of the cell (mouse enter/leave events). When i drag something over the cell, the mouse enter/leave events no longer fires. Is this a bug or by design?

I have the DropQueryEvent wired to each user control in the cells and when i drag onto the cell the DropQueryEvent fires for the user control the drag enters. I can determine this way when a drag enters the cell  the usercontrol in the cell changes its own back color, however, i can't tell when the drag leaves the cell so i can change it back.

Basically i am trying to implement a DropHighlight and i've hit a wall. Maybe i'm missing something obvious.

Please help!

Thanks.






3 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 16 Sep 2010, 09:56 AM
Hi Kim,

 You would need to keep an instance of the previously highlit UserControl in a field, so that when DropQuery fires for a new UserControl, you restore the Background of the previous UserControl.

Sincerely yours,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kim
Top achievements
Rank 1
answered on 16 Sep 2010, 06:51 PM
Thanks for you reply.

I found a better way.

If I add event handlers to the usercontol itself, the dragdrop manager will actually fire a "Dropimpossible" status when the drag leaves the usercontrol. So now I have basically created a DragEnter and DragLeave event for each user control. Works very slick!

The usercontrol now has its own drop functionality and I can handle the event by setting e.Handled = true to prevent it from propagating.

When a dragged item enters a usercontrol, the usercontrol I can check to see if the item being dragged is approporiate for itself and behave accordingly.

if you want to see a sample of it working  http://www.dobranski.ca

Thanks.

0
Justin
Top achievements
Rank 1
answered on 19 Nov 2010, 05:36 AM
Kim-

Thank you so much for sharing.
Your suggestion work perfectly.
// OnDropInfo event handler
private void OnDropInfo(object sender, DragDropEventArgs e)
{
    if (e.Options.Status == DragStatus.DropImpossible)
    {
        removeHighlight(); //... my code to remove highlight
    }
  
    // Drop has completed successfully
    if (e.Options.Status != DragStatus.DropComplete) return;
  
    //... my code here to handle the drop
  
    e.Handled = true;
}

removeSwimlaneHighlight();
}
if (e.Options.Status == DragStatus.DropImpossible)
{
removeSwimlaneHighlight();
}
if (e.Options.Status == DragStatus.DropImpossible)
{
removeSwimlaneHighlight();
Tags
DragAndDrop
Asked by
Kim
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Kim
Top achievements
Rank 1
Justin
Top achievements
Rank 1
Share this question
or