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

Drag and Drop in examples

2 Answers 180 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Derek
Top achievements
Rank 1
Derek asked on 29 Apr 2011, 02:23 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 29 Apr 2011, 02:45 PM
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
0
Derek
Top achievements
Rank 1
answered on 02 May 2011, 02:50 AM
Many thanks for the quick response.  Worked perfectly.
Tags
DropDownList
Asked by
Derek
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Derek
Top achievements
Rank 1
Share this question
or