Skip to content

[WinForms] API validate if the ListVIew is in virtual mode and throws an InvalidOperationException #26021

@SergeySmirnov-Akvelon

Description

@SergeySmirnov-Akvelon

Selected API validate if the ListVIew is in virtual mode and throws an InvalidOperationException.

Selected API validate if the ListVIew is in virtual mode and throws an InvalidOperationException where previously a InvalidOperationException could be thrown, if the APIs were invoked for the ListView in virtual mode and with the created Handle.
The new InvalidOperationException is more obvious to developers. In addition, it closes a workaround where the developer could add a ListViewGroup to the ListView before the Handle was created.

Old behavior

The listed API would throw InvalidOperationException if invoked for ListView is in virtual mode and with the created Handle.
image

New behavior

The listed API would throw InvalidOperationException if invoked for ListView is in virtual mode.
image

Reason for change

Remove the workaround that allowed a developer to add a ListViewGroup to a ListView in virtual mode. Make the InvalidOperationException more understandable for the developer.

Recommended action

  • Review and, if necessary, update the code to prevent the ListViewGroup from being added to the ListView in virtual mode in the listed API.
  • If the code is handling ArgumentNullException replace (or supplement) it with handling ArgumentNullException with more friendly message.

Category

  • Windows Forms

Version introduced: .NET 6.0 RC2 + 7.0 Preview1

Affected APIs

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions