This is a migrated thread and some comments may be shown as answers.
Drag and Drop on GridView Item
1 Answer 57 Views
This is a migrated thread and some comments may be shown as answers.
Frustrated Dev
Top achievements
Rank 1
Frustrated Dev asked on 29 Mar 2010, 03:12 PM
Hello,

I'm trying to drag and drop onto an item within a GridView. I know how to drag an element onto a GridView. However, I would like to know which item within the GridView I'm dropping an element onto. Is there a way to do this? If so, how?

I tried setting the event handlers in my section that looks like this:
                                        <telerik:RadGridView.RowStyle>
                                            <Style TargetType="gridview:GridViewRow">
                                                <Setter Property="telerikDragDrop:RadDragAndDropManager.AllowDrag" Value="True" />
                                            </Style>
                                        </telerik:RadGridView.RowStyle>
but I did not have any luck.

Thank you for your help!

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 30 Mar 2010, 10:17 AM
Hello Frustrated Dev,

If you want to get the cell in which you are dropping the dragged item, it is best to set the AllowDrop on the GridViewCell like this:

<telerikGrid:RadGridView x:Name="radGridView2"  >
      <telerikGrid:RadGridView.Resources>
            <Style TargetType="{x:Type telerikGridView:GridViewCell}">
                  <Setter Property="telerikDragDrop:RadDragAndDropManager.AllowDrop" Value="True" />
            </Style>
       </telerikGrid:RadGridView.Resources>           
</telerikGrid:RadGridView>


This way in the e.Destination you'll see the GridCell you need.

I prepared an example illustrating how you can drag and drop items from one grid to another.
In the first grid (radGridView1) I set the AllowDrag and AllowDrop on the GridViewRows, while in the second one (radGridView2) I set the AllowDrop on the GridViewCell (as described above) and the AllowDrag on the GridViewRows.

In the OnDropInfo() event handler when the drop has completed, I check whether the e.Options.Destination is a Telerik.Windows.Controls.GridView.GridViewCell and if it is, you can easily access the column header, for example.

Please take a look at the example and let me know if it works for you or if you need more info.

Greetings,
Tina Stancheva
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.
Asked by
Frustrated Dev
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or