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

Niranjan Kumar Gopalan 61 Reputation points
2021-06-28T09:21:47.573+00:00

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;  
            }  
        }  
    }  
}  
Developer technologies Windows Forms
{count} votes

1 answer

Sort by: Most helpful
  1. Karen Payne MVP 35,586 Reputation points Volunteer Moderator
    2021-06-28T12:58:54.513+00:00

    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

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.