PropertyGrid randomly loses toolbar items
See original GitHub issue.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:
DarcUI.dll!DarcUI.ExtendedPropertyGrid.ToolStripButton2.OnParentChanged(System.Windows.Forms.ToolStrip oldParent = {System.Windows.Forms.PropertyGridToolStrip}, System.Windows.Forms.ToolStrip newParent = null) Line 29 C#
> System.Windows.Forms.dll!System.Windows.Forms.ToolStripItem.SetOwner(System.Windows.Forms.ToolStrip newOwner) Line 3910 C#
System.Windows.Forms.dll!System.Windows.Forms.ToolStripItemCollection.OnAfterRemove(System.Windows.Forms.ToolStripItem item = {DarcUI.ExtendedPropertyGrid.ToolStripButton2}) Line 443 C#
System.Windows.Forms.dll!System.Windows.Forms.ToolStripItemCollection.Clear() Line 225 C#
System.Windows.Forms.dll!System.Windows.Forms.PropertyGrid.SetupToolbar(bool fullRebuild) Line 4302 C#
System.Windows.Forms.dll!System.Windows.Forms.PropertyGrid.OnSystemColorsChanged(System.EventArgs e = {System.EventArgs}) Line 4508 C#
System.Windows.Forms.dll!System.Windows.Forms.Control.OnSystemColorsChanged(System.EventArgs e = {System.EventArgs}) Line 11230 C#
System.Windows.Forms.dll!System.Windows.Forms.Control.OnSystemColorsChanged(System.EventArgs e = {System.EventArgs}) Line 11230 C#
System.Windows.Forms.dll!System.Windows.Forms.Control.OnSystemColorsChanged(System.EventArgs e = {System.EventArgs}) Line 11230 C#
System.Windows.Forms.dll!System.Windows.Forms.Control.OnSystemColorsChanged(System.EventArgs e = {System.EventArgs}) Line 11230 C#
System.Windows.Forms.dll!System.Windows.Forms.Control.UserPreferenceChanged(object sender, Microsoft.Win32.UserPreferenceChangedEventArgs pref) Line 13440 C#
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.
Issue Analytics
- State:
- Created 4 months ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
PropertyGrid randomly loses toolbar items
Windows Forms is a .NET UI framework for building Windows desktop applications. - PropertyGrid randomly loses toolbar items · dotnet/winforms@4aa5492.
Read more >Problem with Dock Manager and Toolbars Manager
Upon running the program, the form in the designer loses its toolbar and entire top dock area turns black...the program runs and the...
Read more >How to display a dynamic object in property grid?
The main problem here is that the PropertyGrid control doesn't allow to edit, nor uses appropriate editing tools for property DefaultValue which ...
Read more >Extending the PropertyGrid with a new PropertyTab
Implementing two more custom TypeDescriptors. After having the FieldMemberDescriptor implemented and tested I was still missing one feature in ...
Read more >PropertyGrid.ToolbarVisible Property (System.Windows. ...
Gets or sets a value indicating whether the toolbar is visible.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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
OnSystemColorsChangedevent.@merriemcgaw I am fairly sure it would be an API change. So .NET9 makes the most sense.