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

Determining row AND column of a drop operation

1 Answer 45 Views
GridView
This is a migrated thread and some comments may be shown as answers.
GEB
Top achievements
Rank 1
GEB asked on 28 Feb 2009, 03:00 PM
I have implenented the DragAndDrop manager with the RadGridView.  When I drag an object to the grid, I can determine which row is the destination, but I cannot determine the column.  I want to be able to determine the row AND column, or use a key-modifier (such as shidt/ctrl, etc) to determine the intent of the user.  For example, to drop the item into one of the columns the user simply drags to the row.  But to drag to the other column in the same row, the user presses SHIFT while dragging.  But, in the DragDrop Manager, I have not been able to determine a way of determining whether the SHIFT (or CTRL) key is pressed while dragging.  Bottom line, i want to drag the same object to two differnt columns in the same row, and need a way to distinguish the user's intent.  Any ideas?

1 Answer, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 02 Mar 2009, 03:05 PM
Hello Gary,

There is a very easy way to check whether the Control / Shift / Alt are pressed: the Keyboard static class has a property Modifiers:

Keyboard.Modifiers 

Then getting the cell column will require a bit of code. 

Since  the DragDrop events are attached to the GridRows and there is no easy way to attach them to the cells, you will always get GridRows as Source/Destination in the Drag/Drop events.

But then how to get the GridViewCells? For the time being you can use the VisualTreeHelper.FindElementsInHostCoordinates method. It takes a point and a visual root as arguments, you can pass the Application root and the e.Options.CurrentDragPoint. It will return an enumerator to all the visual objects under this point (the mouse). You can foreach them and reach the GridViewCell.

Then, when you have the GridViewCell, you can get the Column from its property with the same name.

This is not a very "clean" approach but it is the only workaround that I can think of currently.

Hopefully this will work for you,

Kind regards,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
GEB
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Share this question
or