Drag and Drop in examples

3 posts, 1 answers
  1. Derek
    Derek avatar
    5 posts
    Member since:
    Feb 2008

    Posted 29 Apr 2011 Link to this post

    In the drag and drop example (the standard telerik examples that is) for dropdown and list drag drop, you get visual feedback when moving the items from one list to the other.  I have found that it is quite easy to get a feedback item to stay drawn when the drop is not completed.  This is generally seen in the area between the lists.  I have attached a screenshot that clearly shows the issue.  Any hints on what needs to be changed to avoid this?
    I have a real life example very close to the telerik example and can see the issue there as well.  If I can do it in testing you can be sure some user will...

    On a similar note:  I can convert the example drag drop manager code to do multi-select drag and drop (the scenario is fairly simple, and many of the standard drag drop cases can be ignored).  Where does the text for the drag feedback form get drawn?  i.e. I can see the feeback form created, but it wasn't immediately clear where the text was being added.  I would like to change the size of the feedback form according to the number of items selected, and also draw the text of the additional items if it is not too hard.

  2. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 29 Apr 2011 Link to this post

    Hello Derek,

    Just dispose of the OutlineForm in the PrepareDragging method, like so:
    private void PrepareDragging(MouseEventArgs e)
    {
        if (this.outlineForm != null)
        {
            this.outlineForm.Close();
            this.outlineForm.Dispose();
            this.outlineForm = null;
        }
     
     //.... rest of the code

    In the same method, the list items are being rendered as bmp's, in my point of view just use a method that will draw multiple items to a bmp and then set the size of the form in the following lines:
    this.outlineForm.BackgroundImage = this.draggedItem.VisualItem.GetAsBitmap(Brushes.Transparent, 0, new SizeF(1, 1)); // create a method that will return an image with the dragged elements
    this.outlineForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    this.outlineForm.Size = this.outlineForm.BackgroundImage.Size; // specify the size here based on the number of selected items
    this.outlineForm.MinimumSize = this.outlineForm.BackgroundImage.Size; // set the minimum size based on the number of items
    this.outlineForm.Location = new Point(Cursor.Position.X + 2, Cursor.Position.Y + 2);

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga

    Telerik WinForms MVP
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Derek
    Derek avatar
    5 posts
    Member since:
    Feb 2008

    Posted 01 May 2011 Link to this post

    Many thanks for the quick response.  Worked perfectly.
Back to Top