I have two RadListBoxes I am able to drag and drop items between the two without problems, but I have one specific RadlistItem that when I add it to the other listbox I want to remove the existing list items in the code behind, but so far it keeps giving and error like Outside Index or something similar when I try to remove those list Items. Any help or Ideas would be appreciated.
7 Answers, 1 is accepted
Here is a sample implementation that clears the destination ListBox items if the "Item 3" item is transferred:
Error Message: Non-negative number required. Parameter name: capacity
If I drag and drop (at the bottom of the list box) it works.
If I drag and drop (at the top of the list box or insert in the middle of
what's already there) I get the error.
Thanks for the help so far.
Is it possible to replicate the issue with the markup that I have provided?
If yes, please provide more detailed reproduction steps (a screencast would be the best) so that we can check it on our side.
If not, please prepare a sample runnable project showing the issue and attach it to an official support ticket. That would allow us to investigate locally your exact scenario and provide more accurate and specific suggestions.
Once we have a solution, we can share it here for convenience and better visibility from the community.
There are two Radlistboxes.
When the application initially executes there will be 32 teams plus a
"FINAL" team within the first listbox. Users are free to drag and drop between the two listboxes, however, when the
"FINAL" team is dragged over to the 2nd listbox then anything that was
previously in the 2nd listbox needs to be deleted/removed.
I have attached the code if it would be easier I could send a zip file with the solution that way you don't have to set it up let me know.
The removing of the items should not be done in the Transferred event. I recommend using the OnTransferring event and then you can call the Items.Clear() method so that you remove all the items before the FINAL item is added to the destination:
Your method works when dragging final to the bottom of the listbox, but when you drag it to the top or middle of Items it throws an error still. Non-negative number required.
Parameter name: capacity.
The issue is actually due to the fact that the code changes the items' collection and the internal transferring handler relies on it.
Another approach that I have tested and it seems to work is removing the items in the PreRender of the RadListBox instead of in the transfer events: