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

Drag Drop

4 Answers 237 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 2
Dan asked on 11 Oct 2007, 11:23 PM
How do I do a drag and drop from one radlistbox control to another? I have done it in the past with two of the stock winforms listbox controls.

4 Answers, 1 is accepted

Sort by
0
Angel
Telerik team
answered on 12 Oct 2007, 09:02 AM
Hello Dan,

Thank you for contacting us.

In response to your question: you just need to select an item and drop it over the other ListBox. See the attached movie for a demonstration.

We support drag-and-drop since Q1 2007. Please find our latest release - Q2 2007 ServicePack 1 available on our website. Remember to uninstall the old version of our product before installing the new one to make sure your projects are referencing the latest version of the product.

Please, let us know if we could be of any further assistance.

Sincerely yours,
Angel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Dan
Top achievements
Rank 2
answered on 12 Oct 2007, 01:29 PM
Sorry, I meant at "runtime", not design time.

0
Dan
Top achievements
Rank 2
answered on 12 Oct 2007, 03:05 PM
I am starting to figure it out. The following will move an item from one list to another. Item is put at the end of the recipient list.

private void radListBox1_MouseDown(object sender, MouseEventArgs e)
{
    if (radListBox1.GetElementAtPoint(e.Location).GetType() == typeof(RadListBoxItem))
    {
        RadListBoxItem item = (RadListBoxItem)radListBox1.GetElementAtPoint(e.Location);
        radListBox1.SelectedItem = item;
        radListBox1.DoDragDrop(item, DragDropEffects.Move);
    }
}

private void radListBox2_DragEnter(object sender, DragEventArgs e)
{
     e.Effect = DragDropEffects.Move;
}

private void radListBox2_DragDrop(object sender, DragEventArgs e)
{
   
    RadListBoxItem item = (RadListBoxItem) e.Data.GetData(typeof(RadListBoxItem));
    RadListBoxItem newitem = new RadListBoxItem(item.Text, item); //is this how to "clone" an item?
    radListBox2.Items.Add(newitem);
    radListBox1.Items.Remove(item);
}

0
Angel
Telerik team
answered on 12 Oct 2007, 03:35 PM
Hello Dan,

We currently don't support drag-and-drop inside a ListBox or between two ListBoxes. Still, this is a valuable suggestion, and we awarded you 600 telerik points.

We will put this task in our todo list, but we cannot commit on a timeframe when it will be implemented.

In order to implement your own custom drag-and-drop, you can use the SelectedItems property if you wish to drag-and-drop the selection, or the SelectedElement property if you wish to find the item that is under the mouse pointer.

Note that, depending on the value of the SelectionMode property, multiple items could be selected. If you need to drag-and-drop the selected items, you can use the SelectedItems property. If you wish to drag-and-drop the item that is under the mouse pointer, you can use the SelectedElement property.

If you need to move an item, you can reuse the item that is being dragged. Just remove it from the source ListBox before adding it to the destination list box. Currently , cloning items is unavailable.

Thank you for contacting us. We appreciate your feedback.

Regards,
Angel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
Dan
Top achievements
Rank 2
Answers by
Angel
Telerik team
Dan
Top achievements
Rank 2
Share this question
or