diff options
author | Александр Хухлаев <sancheolz@gmail.com> | 2021-04-13 16:05:04 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-13 16:05:04 +0300 |
commit | 2b02c02ece6723143d45586772430e89a88bff97 (patch) | |
tree | 39292f28dae445421941b6384d892a859f9ac765 /mcs | |
parent | 86750c250d19902982a84d1f4c40bc300b044e27 (diff) |
[WinForms] When the ListView has VirtualMode=true, calling the Clear method for Items should not throw an exception. This is how .NET behaves (#20877)
Diffstat (limited to 'mcs')
-rw-r--r-- | mcs/class/System.Windows.Forms/System.Windows.Forms/ListView.cs | 2 | ||||
-rw-r--r-- | mcs/class/System.Windows.Forms/Test/System.Windows.Forms/ListViewTest.cs | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/ListView.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/ListView.cs index 13cda57f3ab..49644175907 100644 --- a/mcs/class/System.Windows.Forms/System.Windows.Forms/ListView.cs +++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/ListView.cs @@ -5156,8 +5156,6 @@ namespace System.Windows.Forms public virtual void Clear () { - if (owner != null && owner.VirtualMode) - throw new InvalidOperationException (); if (is_main_collection && owner != null) { owner.SetFocusedItem (-1); owner.h_scroll.Value = owner.v_scroll.Value = 0; diff --git a/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/ListViewTest.cs b/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/ListViewTest.cs index a71067dc5f4..afef8a6c2da 100644 --- a/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/ListViewTest.cs +++ b/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/ListViewTest.cs @@ -737,6 +737,12 @@ namespace MonoTests.System.Windows.Forms Assert.Fail ("#A3"); } catch (InvalidOperationException) { } + try { + lvw.Items.Clear(); + + } catch (Exception ex) { + Assert.AreNotEqual (typeof (InvalidOperationException), ex.GetType (), "#A4"); + } } [Test] |