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

Add and remove multiple listbox items

1 Answer 261 Views
ListControl
This is a migrated thread and some comments may be shown as answers.
Elizabeth
Top achievements
Rank 1
Elizabeth asked on 06 Apr 2012, 10:31 PM
Hi,
I actually implemented the drag and drop example from the demo. There are two list boxes where I can drag and drop or use a button to move a selected item from one list box to the other.

I would like to modify it so that I can select multiple items and click the "add selected" button or drag them.

Here's how I am currently trying to move selected but it seems to remove all of the items.

private void RemoveSelectedFromListBox(RadListControl sourceListBox, RadListControl targetListBox)
        {
            if (sourceListBox.Items.Count == 0) { return; }
            if (sourceListBox.SelectedItems == null) { return; }
 
            for (int i = 0; i < sourceListBox.SelectedItems.Count; )
            {
                RadListDataItem item = sourceListBox.SelectedItems[i];
                sourceListBox.Items.Remove(item);
                targetListBox.Items.Add(item);
            }           
        }

Do you have an example for the drag and drop of multiple selected items? and do I use MultiExtended or MultiSimple?

Thank you,
Beth

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 09 Apr 2012, 04:40 PM
Hello Elizabeth,

Please find attached a sample project which demonstrates how you can move a group of items (the selected ones) from one RadListControl to another. The implementation in this sample project allows you to move the items on a button click or on a drag and drop operation. Please note that the drag'n'drop outline will still only represent the item that is actually being dragged, as due to the virtualization enhancements of the control you are not able to get the visual representation of all selected items.

I hope this helps.

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