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

Drag and Drop between RadGridViews... again

2 Answers 515 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 13 Sep 2011, 03:11 PM
After wrestling with this for a while and doing lots of research I have not been able to find a definitive answer.  I can find a myriad of examples about drag and drop between other controls and the RadGridView but little to no examples about dragging from or between these types of controls.  Searching back it seems that this is a hot topic for the past two years with solutions that temporarily worked or didn't at all.  I'd like to say that I've tried harder for a solution but simply don't know how at this point.  I've usually had wonderful success with the RadDragAndDropManager and all has been simple and easy except in this case.  I just want to be able to drag a row from one RadGridView to another using the standard RadDragAndDropManager methods.

My main issue at this point is that I can't get a row to drag at all.  I've tried applying a style to my GridView's RowStyle and to my column's CellStyle that sets the telerik:RadDragAndDropManager.AllowDrag to true but nothing happens.  Strangely enough if I set telerik:DragDropManager.AllowDrag equal to true I get some dragging ability but it always says I have an invalid drop target by showing the crossed out circle curser.

Below is a simple application that I think should work but doesn't.  I haven't bothered to set the drop properties yet.  Please give me some pointers or an example that I can study to know what to do on this that is relevant to .NET 4.0 and recent releases.  I am currently using the latest internal build as of 9/12/2011.

Thanks,
Adam
<Window
    x:Class="RadGridView_DragAndDropTest.MainWindow"
    x:Name="Window"
    Title="MainWindow"
    Width="640" Height="480">
 
    <Window.Resources>
        <Style TargetType="telerik:GridViewRow">
            <Setter Property="telerik:RadDragAndDropManager.AllowDrag" Value="True"/>
        </Style>
    </Window.Resources>
 
    <Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.45*"/>
            <ColumnDefinition Width="0.1*"/>
            <ColumnDefinition Width="0.45*"/>
        </Grid.ColumnDefinitions>
        <telerik:RadGridView HorizontalAlignment="Right" Width="280.8" ShowGroupPanel="False" SelectionMode="Extended" AutoGenerateColumns="False" CanUserFreezeColumns="False" CanUserReorderColumns="False" ColumnWidth="*" DataContext="{Binding Source={StaticResource SampleDataSource}}" ItemsSource="{Binding Collection}">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Property1}"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
        <telerik:RadGridView Grid.Column="2" d:LayoutOverrides="Width, Height" ShowGroupPanel="False" SelectionMode="Extended" AutoGenerateColumns="False" CanUserFreezeColumns="False" CanUserReorderColumns="False" ColumnWidth="*" DataContext="{Binding Source={StaticResource SampleDataSource1}}" ItemsSource="{Binding Collection}">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Property1}"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>
</Window>

2 Answers, 1 is accepted

Sort by
0
Adam
Top achievements
Rank 1
answered on 13 Sep 2011, 03:14 PM
The method of setting the RowStyle is referenced here http://www.telerik.com/help/wpf/raddraganddrop-between-treeview-gridview.html
0
Accepted
Tsvyatko
Telerik team
answered on 17 Sep 2011, 09:55 AM
Hello Adam,

 There are several options to enable drag between two radgridviews.

The easiest is to use the code from our rowreorder demo and attach the behavior to gridviews (Demonstrated in WPF.DragInGridsRowReorder project). This however will enable rowreorder within the grid, which can be undesired.

Another option is to take advantage of RadDragAndDropMaanger.AutoDrag property. It will automatically start drag and create suitable dragcue and payload. (Demonstrated in WPF.)

And the final option is to use default drag mechanism (without AutoDrag) similar to this scenario - http://www.telerik.com/help/wpf/raddraganddrop-from-radgridview-to-listbox.html

Let us know if you have any further questions.

Regards,
Tsvyatko
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Adam
Top achievements
Rank 1
Answers by
Adam
Top achievements
Rank 1
Tsvyatko
Telerik team
Share this question
or