ListBox.SelectedIndexCollection modification works but IList versions throw NotSupportedException
See original GitHub issueExample Problems
E.g.
void IList.Clear()
{
    throw new NotSupportedException(SR.ListBoxSelectedIndexCollectionIsReadOnly);
}
public void Clear()
{
    if (owner != null)
    {
        owner.ClearSelected();
    }
}
Also, the properties IsFixedSize and IsReadOnly return true, but this is quite clearly not the case
Proposed Changes
- Modify 
IsFixedSizeandIsReadOnlytofalse - Modify the IList modification methods to call the non-IList methods on the collection: 
Add,Clear,Remove 
Thoughts? This would be breaking, but in the way that is good as we change exception to something functional: see https://github.com/dotnet/runtime/blob/4f9ae42d861fcb4be2fcd5d3d55d5f227d30e723/docs/coding-guidelines/breaking-changes.md
Issue Analytics
- State:
 - Created 3 years ago
 - Comments:7 (7 by maintainers)
 
Top Results From Across the Web
ListBox.SelectedIndexCollection.IList.Remove(Object) ...
This member is an explicit interface member implementation. It can be used only when the ListBox.SelectedIndexCollection instance is cast to an IList interface....
Read more >'Collection is read-only.' thrown when removing object from ...
I have an iListof webelements, and if that element contains the string "WSC", I'd like to remove it from the iList. Can anyone...
Read more >ListBox.cs source code in C# .NET - dotnetframework.org
This is a bug in // the control, but can be easily worked around by removing and ... public class SelectedIndexCollection : IList...
Read more >KryptonCheckedListBox.cs
... InnerArrayIndexOfIdentifier(entryObject, 0); } set { throw new NotSupportedException("Read Only Collection"); } } #endregion #region Private int IList.
Read more >Programação-em-Visual-Basic.NET-(Inglês) - Calaméo
NET Framework level, meaning that regardless of the language in which each component is written, exceptions can be thrown and caught across component...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

If we like this, will implement after #3086
Thanks @hughbe for this proposal. Given this has been the behavior for long and could break migrating applications, we like to wait until there is a real customer scenario here.