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

validate listcontrol items after drag and drop

1 Answer 94 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Elizabeth
Top achievements
Rank 1
Elizabeth asked on 20 Apr 2012, 09:28 PM
Hi,

I have implemented the RadItemDragDropManager example that allows me to drag multiple list items from one list control to another.

I need to validate that the user is not dragging certain incompatible list items into the destination list control.

The problem is that when dragging multiple items, the selected items collection isn't really preserved.

How can I compare the items being dragged to the items in the destination list control?

Thank you!
Beth

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 23 Apr 2012, 03:10 PM
Hi Elizabeth,

Thank you for contacting Telerik support.

I would like to clarify that RadItemDragDropManager example does not support scrolling and you can Drag&Drop only visible items. I can suggest checking the items in BeginDrag method. For example:
private void BeginDrag(MouseEventArgs e)
{
    RadListDataItem[] selectedItems = new RadListDataItem[ this.sourceListBox.SelectedItems.Count];//TODO Count!=0
    this.sourceListBox.SelectedItems.CopyTo(selectedItems,0);
    foreach (RadListDataItem item in selectedItems)
    {
        if(item.Text.Contains("Tuna Salad"))//exclude this item from D&D
        {
            item.Selected = false;
        }
    }
I hope this will be useful for you. Should you have further questions, I would be glad to help.

Greetings,
Peter
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
DropDownList
Asked by
Elizabeth
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or