Skip to content

ControlDesigner can not be used in .NetCore winform,but it works in .Net Framework,how to use it in .Net Core winform #4886

@paxtonxuhongzhi

Description

@paxtonxuhongzhi

ControlDesigner can not be used in .NetCore winform,but it works in .Net Framework,how to use it in .Net Core winform
92764-image.png

92764-image

Such as this(Framework),the panel in framework work well,it visable in designer and controable,but in .Net Core,it just exist but can not use.
92677-image
92677-image.png
such as this(.Net Core)

my code as follow,

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace WindowsFormsAppNetCore
{
[Designer(typeof(LDesigner))]
[DesignTimeVisible(true)]
public class MenuControlEx : SetterControl
{
public MenuControlEx()
{
InitializeComponent();
}
/// <summary>
/// Panel
/// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public Panel MenuPanel
{ get { return setterPanel; } }

     private void InitializeComponent()
     {
         this.setterPanel = new System.Windows.Forms.Panel();
         this.SuspendLayout();
         // 
         // setterPanel
         // 
         this.setterPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
         | System.Windows.Forms.AnchorStyles.Left) 
         | System.Windows.Forms.AnchorStyles.Right)));
         this.setterPanel.AutoScroll = true;
         this.setterPanel.Location = new System.Drawing.Point(104, 66);
         this.setterPanel.Name = "setterPanel";
         this.setterPanel.Size = new System.Drawing.Size(355, 413);
         this.setterPanel.TabIndex = 0;
         // 
         // MenuControlEx
         // 
         this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
         this.Controls.Add(this.setterPanel);
         this.ItemContainer = this.setterPanel;
         this.Name = "MenuControlEx";
         this.Size = new System.Drawing.Size(482, 508);
         this.ResumeLayout(false);
     }
     private System.Windows.Forms.Panel setterPanel;
 }
 //system.Desgin
 public class LDesigner : ParentControlDesigner
 {
     private MenuControlEx _control;
     public override void Initialize(IComponent component)
     {
         base.Initialize(component);
         _control = (MenuControlEx)component;
         bool succ = this.EnableDesignMode(_control.MenuPanel, "setterPanel");
         if (!succ)
             throw new Exception("");
     }
 }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-VSDesignerWindows Forms out-of-proc designer related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions