GridView to PropertyGrid Drag Drop service

2 posts, 0 answers
  1. Darren
    Darren avatar
    1 posts
    Member since:
    Jun 2013

    Posted 24 May Link to this post

    using the Drag Drop Service i cant get the e.HitTarget to return true no matter what propertygrid reference i use must be missing something here.

    basically i just want to recreate the propertygrid items when a GridDataRowElement is dragged onto a propertygrid.

     

    private void svc_PreviewDragOver(object sender, RadDragOverEventArgs e)
    {

    if (e.DragInstance is GridDataRowElement)
    {
    e.CanDrop = e.HitTarget is PropertyGridElement;
    }
    }

  2. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 24 May Link to this post

    Hello Darren,

    Thank you for writing. 

    If your RadPropertyGrid is populated with items, note that the HitTaret is supposed to be the visual item element. You can find below a sample code snippet demonstrating how to allow dragging over the items in RadPropertyGrid:
    RadDragDropService svc = this.radGridView1.GridViewElement.GetService<RadDragDropService>();
    svc.PreviewDragOver += DragDropService_PreviewDragOver;
    this.radPropertyGrid1.ItemFormatting += radPropertyGrid1_ItemFormatting;

    private void radPropertyGrid1_ItemFormatting(object sender, PropertyGridItemFormattingEventArgs e)
    {
        e.VisualElement.AllowDrop = true;
    }
     
    private void DragDropService_PreviewDragOver(object sender, RadDragOverEventArgs e)
    {
        if (e.HitTarget is PropertyGridItemElement)
        {
            e.CanDrop = true;
        }
    }

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    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.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top