WinForms (.NET 8): How to open a Form or UserControl from a property in a UserControl (Designer support)

1 week ago 9
ARTICLE AD BOX

I am working with C# and WinForms on .NET 8.

I have a simple UserControl:

using System; using System.ComponentModel; using System.Drawing.Design; using System.Windows.Forms; using System.Windows.Forms.Design; namespace mhk__SandBox { public partial class ucMHK : UserControl { public ucMHK() { InitializeComponent(); } } }

In the same project, I also have:

a Form (frmProps)

another UserControl (ucProps)

What I want to achieve is:

Add two properties to ucMHK

When I click the first property in the PropertyGrid (designer), it should open frmProps

When I click the second property, it should open ucProps

I was able to achieve this behavior in .NET Framework 4.8.1 (most likely using a custom editor like UITypeEditor), but I have not been able to make it work in .NET 8 despite trying for several days.

Has anything changed in .NET 8 WinForms designer regarding this scenario?
What is the correct approach to open a Form or UserControl from a property in the designer?

Any help or working example would be greatly appreciated.

Read Entire Article