Je crée mon propre contrôle utilisateur qui contient uniquement un panneau:C# contrôle utilisateur comme un panneau personnalisé
Quand je fais glisser un objet MyPanel dans le concepteur et puis essayer d'ajouter un bouton dessus, le bouton est en fait ajouté aux contrôles du formulaire.
Y at-il une propriété/attribut que je dois définir pour effectuer cela, une autre façon de faire ce que je veux?
public class MyPanel : UserControl
{
private Panel panelMain;
public MyPanel()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.panelMain = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// panelMain
//
this.panelMain.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.panelMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelMain.Location = new System.Drawing.Point(0, 0);
this.panelMain.Name = "panelMain";
this.panelMain.Size = new System.Drawing.Size(150, 150);
this.panelMain.TabIndex = 0;
//
// myPanel
//
this.Controls.Add(this.panelMain);
this.Name = "MyPanel";
this.ResumeLayout(false);
}
}
C'est ce que je cherche. En ce qui concerne l'héritage, j'ai simplement simplifié le problème et, bien sûr, j'avais besoin de quelque chose de plus compliqué. – Toto