I have 2 panel in my Control.
panel 3 added to panel 1 for Title , panel 2 added to panel 1 For Content & panel 1 is My Control
I do create this Control For my Project . this Control Code:
public class ControWithTitle : Panel // Panel 1
{
public Panel Title = new Panel { Dock = DockStyle.Top, Height = 20, BackColor = Color.Black }; // Panel 2
public Panel Content = new Panel { Dock = DockStyle.Fill, BackColor = Color.White }; // Panel 3
public ControWithTitle ()
: base()
{
this.Controls.Add(Title);
this.Controls.Add(Content);
}
}
I do When Add This control in Form > Create Design Mode For Content . not panel 1 Or Title Panel....
this Code not Work ... All Panel is Lock . after Build Project , every Changed was reset...
is work this true? How to create this?
╔═══════════╗ < Paenl 1
║╔═════════╗║
║║ Panel 2 ║║
║╚═════════╝║
║╔═════════╗║
║║ ║║
║║ ║║
║║ ║║
║║ Panel 3 ║║ < Design Mode For This Paenl
║║ ║║
║║ ║║
║║ ║║
║╚═════════╝║
╚═══════════╝
after pasted Dear @King's Code My Problem Not Solved... This Error has in my project:
this is my Code for a Other Sample After (@Hans Passant & @King King) Answer:
[Designer(typeof(CustomDesigner))]
public partial class ControlWithTitle : UserControl // Panel 1
{
private System.ComponentModel.IContainer components = null;
private ListView listView1 = new ListView();
protected override void Dispose (bool disposing)
{
if (disposing && (components != null)) { components.Dispose(); }
base.Dispose(disposing);
}
private void InitializeComponent ()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(listView1);
}
public Panel Title = new Panel { };
public Panel Content = new Panel { };
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ListView Employees { get { return listView1; } }
public ControlWithTitle ()
{
InitializeComponent();
}
}
public class CustomDesigner : ParentControlDesigner
{
public override void Initialize (IComponent component)
{
ControlWithTitle control = Control as ControlWithTitle;
if (control != null)
{
EnableDesignMode(control.Employees, "Employees");
}
}
}
You can try this code, you have to add reference to the System.Design.dll
and using System.Windows.Forms.Design;
:
[Desiner(typeof(CustomDesigner))]
public class ControWithTitle : Panel // Panel 1
{
//....
}
public class CustomDesigner : ParentControlDesigner {
public override void Initialize(IComponent component){
ControWithTitle control = Control as ControWithTitle;
if(control != null){
//Enable designmode for Panel3
EnableDesignMode(control.Content, "Content");
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.