Open RussKie opened 1 year ago
Thanks @RussKie! @JeremyKuhne will take a look.
I don't know whether it worked in .NET Framework - there is no option for that. I suspect that it never did, so it probably isn't a regression.
@RussKie can you give a quick explanation of how you are adding the items to the toolstrip? I was trying to repo.
It looks like its caused by a fullRebuild
which can happen when
ToolbarVisible
is toggled to true and _tabsDirty
has been set by one of the tab operationsOnSystemColorsChanged
OnLayoutInternal
when the DPI changesfullRebuild does not keep the existing buttons because they might not be needed anymore because the associated PropertyTab
might have been removed. So it really depends how you are adding the toolstripitems.
Here's the sample: https://github.com/RussKie/DarcUI/blob/930a9c8caac48a185e6bb277aeb2b7bc9fbe5741/src/DarcUI.WinForms/CustomControls/ExtendedPropertyGrid.cs#L51-L58 https://github.com/RussKie/DarcUI/blob/930a9c8caac48a185e6bb277aeb2b7bc9fbe5741/src/DarcUI.WinForms/CustomControls/ExtendedPropertyGrid.cs#L125-L137
I observed the issue to occur whenever I have my little app running and I launch VS, which triggers OnSystemColorsChanged
event.
I'm going to remove the regression tagging because it doesn't really look like one. We'll investigate, but we're getting late enough into .NET 8 that I can't promise a fix would make it. Really, .NET 9 is more realistic if it turns out to be a runtime issue and not something you can address on the application side.
@merriemcgaw I am fairly sure it would be an API change. So .NET9 makes the most sense.
.NET version
Microsoft.WindowsDesktop.App 6.0.16
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
No idea
Issue description
I have an app with a
PropertyGrid
control, which is customised with few extra buttons.I observed that the custom buttons randomly disappear. Here's the trace of the issue:
The issue appears to be here: https://github.com/dotnet/winforms/blob/89fcc580afb06911254f00cfc6650b0496c033ad/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.cs#L3940-L3944
The
buttonList
is rebuilt from only pre-defined elements, completely ignoring any additional elements the toolstrip contained.Steps to reproduce
I can craft a sample, if necessary.