dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.36k stars 967 forks source link

PropertyGrid.RemoveTabType does not effectively remove tab #10574

Closed thomasnaletsg closed 8 months ago

thomasnaletsg commented 8 months ago

.NET version

8.0.100

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

Yes, it works in 5.0

Issue description

The PropertyGrid.RemoveTabType method does not effectively remove the PropertyTab. Calling this method with a previously added tab does not suppress the tab. It looks like the check on type is wrong in the method RemoveTabType since the commit https://github.com/dotnet/winforms/pull/6108

The type check is not consistent between AddTabType and RemoveTabType method: In AddTabType: https://github.com/dotnet/winforms/blob/39c1cfba04f0682ae79e6629188eb291bc0d203e/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.cs#L1480

In RemoveTabType: https://github.com/dotnet/winforms/blob/39c1cfba04f0682ae79e6629188eb291bc0d203e/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.cs#L3565

Steps to reproduce

  1. Create a new form with a PropertyGrid
  2. Create a class MyPropertyTab which inherits from PropertyTab
  3. Properly implement MyPropertyTab
  4. Call propertyGrid.AddTabType(typeof(MyPropertyTab))
  5. Call propertyGrid.RemoveTabType(typeof(MyPropertyTab))

In .net50, MyPropertyTab is removed in .net80, MyPropertyTab is not removed

Eudora-Li01 commented 8 months ago

Verified this issue on .NET 8.0.200 with dlls built form winforms repo of release/8.0 branch, it was fixed, MyPropertyTab can be removed and added unit tests have passed. RemoveTabType.zip

https://github.com/dotnet/winforms/assets/130345015/33caa8e8-5cab-47ec-aa6c-a26be87855c9

Zheng-Li01 commented 8 months ago

Verified this issue on .NET 9.0.0-alpha.1.24061.5 with dlls built form winforms repo of main branch, it was fixed, MyPropertyTab can be added and removed. 10574

WinFormsApp64.zip

Eudora-Li01 commented 7 months ago

Verified with .NET SDK 8.0.2 test pass build, this issue was fixed. Test result is same as above.

Zheng-Li01 commented 7 months ago

Verified this issue with .NET 9 Preview 1 test pass build, it was fixed. Test result is same as above.