question

NiranjanKumarGopalan-3044 avatar image
5 Votes"
NiranjanKumarGopalan-3044 asked JagadeesanPichaimuthu-4244 commented

ControlDesigner class does not work in .NetCore and .NET5 in the Windows Forms

ControlDesigner class is used for designer related scenario in Windows forms. It works good in .NETFramwork but not in .NetCore and .NET6.

.NET5 :
109817-image.png


.NET Framework:
109798-image.png

Please fix this ASAP or provide a solution.

Code for CustomControl used are below.

 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.ComponentModel.Design;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 using System.Windows.Forms.Design;
    
 namespace Winforms_SmartTag
 {
     [Designer(typeof(CustomControlDesigner), typeof(System.ComponentModel.Design.IDesigner))]
     public class CustomControl : Button
     {
    
     }
    
     public class CustomControlDesigner : ControlDesigner
     {
         System.ComponentModel.Design.DesignerActionListCollection actionLists;
    
         public override DesignerActionListCollection ActionLists
         {
             get
             {
                 if (null == actionLists)
                 {
                     actionLists = new System.ComponentModel.Design.DesignerActionListCollection();
                     actionLists.Add(
                         new CustomControlDesignerActionList(this.Component));
                 }
                 return actionLists;
             }
         }
     }
    
     public class CustomControlDesignerActionList : DesignerActionList
     {
         CustomControl Control;
         public CustomControlDesignerActionList(IComponent component)
             : base(component)
         {
             Control = component as CustomControl;
         }
    
         DesignerActionItemCollection actonListItems = null;
    
         public override DesignerActionItemCollection GetSortedActionItems()
         {
             actonListItems = new DesignerActionItemCollection();
    
             actonListItems.Add(new DesignerActionHeaderItem("Test1"));
    
             actonListItems.Add(new DesignerActionHeaderItem("Test2"));
    
    
             return actonListItems;
         }
    
         public string Name
         {
    
             get
             {
                 string name = string.Empty;
                 if (this.Control != null)
                 {
                     CustomControl control = this.Control as CustomControl;
                     name = control.Name;
                 }
                 return name;
             }
         }
     }
 }








windows-forms
image.png (13.5 KiB)
image.png (20.0 KiB)
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @NiranjanKumarGopalan-3044,
What version of your Visual Studio? As karenpayneoregon said, the Windows Forms Designer for .NET Core projects is currently available as a preview.
More details please refer to this document.
Best Regards,
Daniel Zhang


0 Votes 0 ·

HI @DanielZhang-MSFT ,

I am using VisualStudio 2019 Preview version 16.11 preview 1.

0 Votes 0 ·
DanielZhang-MSFT avatar image DanielZhang-MSFT NiranjanKumarGopalan-3044 ·

Hi @NiranjanKumarGopalan-3044,
This means that this feature is not yet supported in .Net Core, you can refer to karenpayneoregon's answer. Use the “Send Feedback” icon in Visual Studio top-right corner as shown in the following image and specify that it is related to the "WinForms .NET Core" area.
Best Regards,
Daniel Zhang

0 Votes 0 ·
Show more comments

1 Answer

karenpayneoregon avatar image
0 Votes"
karenpayneoregon answered

Hello,

Please report this to Microsoft and note that many features have not yet been implemented as Windows Forms is still in preview mode.

109867-figure1.png



figure1.png (8.1 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.