How can i get a grouptilebox destination after a event dragdrop

2 posts, 0 answers
  1. Cleber
    Cleber avatar
    1 posts
    Member since:
    Aug 2013

    Posted 08 Aug 2013 Link to this post

    When i move a tileElement from the group A to a group B or Group C... how can i know what group the tileElement went? but just after i release the tileElement in the group. 

    i've tried this code:

    public Form1()
    {
        InitializeComponent();
        this.radPanorama1.PanoramaElement.DragDropService.Stopping += new EventHandler<Telerik.WinControls.RadServiceStoppingEventArgs>(DragDropService_Stopping);
    }
     
    void DragDropService_Stopping(object sender, Telerik.WinControls.RadServiceStoppingEventArgs e)
    {
        if (e.Commit)
        {
            RadTileElement tile = this.radPanorama1.PanoramaElement.DragDropService.Context as RadTileElement;
        }
    }
    and then i tried to get tile.parent.parent... but doing this i get the source group... not the destination....
    thanks
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 13 Aug 2013 Link to this post

    Hi Cleber,

    Thank you for writing.

    To identify the group you have dropped a tile to, you can use the PreviewDragDrop event of the DragDropService:
    void DragDropService_PreviewDragDrop(object sender, RadDropEventArgs e)
    {
        TileGroupElement group = GetTargetGroup(new RectangleF(e.DropLocation, ((RadTileElement)e.DragInstance).Size));
     
        if (group != null)
        {
           //this is the target group
        }
    }
     
    protected virtual TileGroupElement GetTargetGroup(RectangleF tileRectangle)
    {
        TileGroupElement result = null;
        float maxIntersection = 0;
     
        foreach (TileGroupElement group in radPanorama1.PanoramaElement.Groups)
        {
            if (tileRectangle.IntersectsWith(group.ControlBoundingRectangle))
            {
                RectangleF intersection = tileRectangle;
                intersection.IntersectsWith(group.ControlBoundingRectangle);
                float surface = intersection.Width * intersection.Height;
                if (surface > maxIntersection)
                {
                    maxIntersection = surface;
                    result = group;
                }
            }
        }
     
        return result;
    }

    I hope that you find this information useful. Let us know if you have any other questions.
     

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