question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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. image

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:open
  • Created 4 months ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
elachlancommented, Jul 27, 2023

@merriemcgaw I am fairly sure it would be an API change. So .NET9 makes the most sense.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found