winforms icon indicating copy to clipboard operation
winforms copied to clipboard

Default CollectionEditor Appears instead of the Custom CollectionEditor When the Editor Opens from the UITypeEditor’s Custom Form

Open SreemonPremkumarMuthukrishnan opened this issue 8 months ago • 8 comments

Environment

Microsoft Visual Studio Professional 2022 (64-bit) - Current Version 17.13.6

.NET version

Facing this issue in both .NET80 and .NET90.

Did this work in a previous version of Visual Studio and/or previous .NET release?

No response

Issue description

A custom CollectionEditor does not appear as expected when invoked from a custom form of a UITypeEditor. Instead, the default CollectionEditor is displayed, which prevents the intended custom editing functionality from being used.

If the CollectionEditor property is directly on the control's class, the custom CollectionEditor appears as expected. However, in our scenario, we are showing this property inside the property grid within the custom form of the UITypeEditor.

We would appreciate any guidance or suggestions on resolving this issue to display the custom CollectionEditor.

In the sample, the MyCollection property is bound with the UITypeEditor, which shows a custom form, and the SubItems property is bound with the Custom CollectionEditor.

Demo link:

CustomControlLibrary_WithSample.zip

NuGet is included in the above file.

Issue replication video:

https://github.com/user-attachments/assets/012ef103-b2ce-44ef-be72-e22bbfbde09b

Steps to reproduce

  1. Open the Designer.
  2. Click the CustomControl and go to the property window.
  3. Now, open the custom form of the "MyCollection" property.
  4. Press the "Add" button.
  5. Open the editor of the "SubItems" property inside the custom form's property grid.

Expected Behavior - The custom Collection Editor should be shown. Observed Behavior - The default Collection Editor was shown.

Note: The same "SubItems" property is directly available on the custom control, and it displays the custom CollectionEditor properly.

Diagnostics


Hi team

Is there any updated regarding this?

Regards, Sreemon Premkumar M.

Please take a look at this blog to find more information about building for the out-of-process designer. There are links to code samples and examples that should help you solve your issues here.

merriemcgaw avatar May 05 '25 22:05 merriemcgaw

I can take a look sometime next week at the earliest.

In the meantime - try to attach a second instance of Visual Studio, to debug into the Editor client-side/server-side at Design Time. Your general approach seems to be fine.

Please note, that if you want to debug into the Server process, that you need to attach both the Visual Studio instance running the WinForms OOP Designer AND the DesignToolsServer, so breakpoints would be hit on both sides.

If that causes problems, use the "Wooden-Mallet-Method": Use Debugger.Launch(), if Debugger.IsAttached returns false at the spots, where you want to see, where things are not getting picked up:

  if (!Debugger.IsAttached)
  {
      Debugger.Launch();
  }

KlausLoeffelmann avatar May 07 '25 17:05 KlausLoeffelmann

Hi @KlausLoeffelmann ,

Just checking in to see if there are any updates regarding this issue.

I will look into it too.

Epica3055 avatar May 29 '25 01:05 Epica3055

There are two mistakes I found in your project. 1.You should configure The PropertyGrid in CustomEditorForm with a Site. 2.Form shouldn't show in Server side.

You can download the project I provide here to see what mean. CustomControlLibrary_WithSample.zip

Besides, there are server blogs you can study, witch I think are very useful. https://devblogs.microsoft.com/dotnet/state-of-the-windows-forms-designer-for-net-applications/ https://devblogs.microsoft.com/dotnet/custom-controls-for-winforms-out-of-process-designer/

Epica3055 avatar May 30 '25 06:05 Epica3055

Hi @Epica3055 ,

Thank you for looking into this issue and providing your assistance. As you mentioned, displaying the form within the client project does allow the CollectionEditor to function as expected.

However, in our scenario, the UITypeEditor form contains logic that depends on custom types defined across two different assemblies, both of which are referenced in the server project. This is why the form is currently displayed from the server side. Including these assemblies in the client project (which targets .NET Framework) is not feasible due to compatibility issues and the form uses custom types with complex dependencies, making it impractical to move those classes to the client project. As a result, we are unable to move the form directly to the client side.

Image

Custom class types in different assemblies:

Image

Reference to CustomControlLibrary:

Image

CustomControlLibrary to Server project:

Image

Could you please advise on how we might move this form—one that depends on custom controls and types—to the client side in a compatible and supported manner? Your guidance on handling this scenario would be greatly appreciated.

Modified Sample:

CustomControlLibrary.zip

I guess you will have to convert 'UITypeEditor' (Form related)and it's dependencies to .NetFramework whatever ways you use. The bottom line is client (.NetFramework) side do the graphic thing (CustomEditorForm in your case). That's what happended when we migrate .NetFramework winform designer to .NetCore winform designer. A lot of code got refactored.

@KlausLoeffelmann what's your opinion ?

Epica3055 avatar Jun 06 '25 09:06 Epica3055