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

DragDrop Between RadPageViews

8 Answers 154 Views
PageView
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 2
Justin asked on 27 Jun 2013, 09:53 AM
Hi

Is it possible to drag and drop pages between two or more RadPageView controls? I used a RadSplitContainer to put two RadPageViews side by side, but can't seem to drag the pages between both of them.

Thanks.

8 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 28 Jun 2013, 03:52 PM
Hi Justin,

Thank you for writing.

You can drag and drop pages from one page view to another and vice-versa using the OLE drag drop. Here is a sample:
public Form1()
{
    InitializeComponent();
 
    this.radPageView1.MouseDown += radPageView1_MouseDown;
    this.radPageView2.MouseDown += radPageView1_MouseDown;
 
    this.radPageView1.AllowDrop = true;
    this.radPageView2.AllowDrop = true;
 
    this.radPageView1.DragEnter += radPageView2_DragEnter;
    this.radPageView2.DragEnter += radPageView2_DragEnter;
 
    this.radPageView1.DragDrop += radPageView2_DragDrop;
    this.radPageView2.DragDrop += radPageView2_DragDrop;
}
 
private void radPageView2_DragDrop(object sender, DragEventArgs e)
{
    RadPageView target = ((RadPageView)sender);           
    RadPageViewPage temp = (RadPageViewPage)e.Data.GetData(typeof(RadPageViewPage));
    RadPageView source = temp.Owner;
    if (target != source)
    {
        target.Pages.Add(temp);
    }
}
 
private void radPageView2_DragEnter(object sender, DragEventArgs e)
{
    e.Effect = DragDropEffects.Move;
}
 
private void radPageView1_MouseDown(object sender, MouseEventArgs e)
{
    RadPageViewStripItem item = ((RadPageView)sender).ElementTree.GetElementAtPoint(e.Location) as RadPageViewStripItem;
 
    if (item != null)
    {
        ((RadPageView)sender).DoDragDrop(item.Page, DragDropEffects.Move);
    }
}

I hope this helps. Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
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
Justin
Top achievements
Rank 2
answered on 29 Jun 2013, 08:19 AM
Hi, 

Can I have VB code instead since I'm using it?

Thanks
0
George
Telerik team
answered on 01 Jul 2013, 02:32 PM
Hi Justin,

Thank you for writing back.

Here is the code in Visual Basic as you asked.
Public Sub New()
    InitializeComponent()
 
    Me.radPageView1.MouseDown += radPageView1_MouseDown
    Me.radPageView2.MouseDown += radPageView1_MouseDown
 
    Me.radPageView1.AllowDrop = True
    Me.radPageView2.AllowDrop = True
 
    Me.radPageView1.DragEnter += radPageView2_DragEnter
    Me.radPageView2.DragEnter += radPageView2_DragEnter
 
    Me.radPageView1.DragDrop += radPageView2_DragDrop
    Me.radPageView2.DragDrop += radPageView2_DragDrop
End Sub
 
Private Sub radPageView2_DragDrop(sender As Object, e As DragEventArgs)
    Dim target As RadPageView = DirectCast(sender, RadPageView)
    Dim temp As RadPageViewPage = DirectCast(e.Data.GetData(GetType(RadPageViewPage)), RadPageViewPage)
    Dim source As RadPageView = temp.Owner
    If target <> source Then
        target.Pages.Add(temp)
    End If
End Sub
 
Private Sub radPageView2_DragEnter(sender As Object, e As DragEventArgs)
    e.Effect = DragDropEffects.Move
End Sub
 
Private Sub radPageView1_MouseDown(sender As Object, e As MouseEventArgs)
    Dim item As RadPageViewStripItem = TryCast(DirectCast(sender, RadPageView).ElementTree.GetElementAtPoint(e.Location), RadPageViewStripItem)
 
    If item IsNot Nothing Then
        DirectCast(sender, RadPageView).DoDragDrop(item.Page, DragDropEffects.Move)
    End If
End Sub

For any further questions, do not hesitate to contact us.
 

Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
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
Justin
Top achievements
Rank 2
answered on 01 Jul 2013, 03:10 PM
Hi again

Thanks for the code! :)
0
Krunal
Top achievements
Rank 1
answered on 14 Jun 2016, 05:30 AM

With drag and drop pages between two or more RadPageView controls, drag(move) pages within RadPageView(below code) stop working.

this.strip = this.radPageView1.ViewElement as RadPageViewStripElement; 
this.strip.ItemDragMode = PageViewItemDragMode.Preview;

Need to drag and drop between radPageView and within radPageView

Thanks.

0
Hristo
Telerik team
answered on 15 Jun 2016, 06:56 AM
Hi Krunal,

Thank you for writing.

The code snippet my colleague sent is working fine on my end. Could you please open up a support ticket and send us your project demonstrating what you are trying to accomplish?

Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
0
Kasim
Top achievements
Rank 2
answered on 25 Aug 2016, 06:49 AM

Hi Hristo,

I am using UI for Window (Desktop application) with 2016 Q2 Telerik controls.

I have RadPageViews in different combinations like:

1. PageViews in different panels (Split/Collapsible).

2. PageView within page view

3. PageView in different RadForms

4. Pages within same page view (ItemDragMode = PageViewItemDragMode.Preview).

I want to have drag drop functionality between all above combinations (except for parent in the ElementTree the pageview cannot be moved within a child pageview). I tried the code snippet shared above but it's not working with me.

In my case only thing that is working is pages within same pageview. When trying to do any other combination, either the application hangs or do nothing.

Can you please share code sample with above combinations working?

0
Hristo
Telerik team
answered on 25 Aug 2016, 03:11 PM
Hello Kasim,

Thank you for writing.

I am attaching a project utilizing the solution as suggested by my colleague. Please check how it runs on your end. It handles all of the mentioned scenarios assuming the controls are located in one form.

Regarding your requirement for drag drop between forms please refer to the following resources: 
I have also included a project handling the described scenarios including a simple example for dragging and dropping pages between two forms.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
Tags
PageView
Asked by
Justin
Top achievements
Rank 2
Answers by
George
Telerik team
Justin
Top achievements
Rank 2
Krunal
Top achievements
Rank 1
Hristo
Telerik team
Kasim
Top achievements
Rank 2
Share this question
or