question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ListBox.SelectedIndexCollection modification works but IList versions throw NotSupportedException

See original GitHub issue

Example 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 IsFixedSize and IsReadOnly to false
  • 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:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
hughbecommented, Apr 19, 2020

If we like this, will implement after #3086

0reactions
dreddy-workcommented, Mar 14, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found