title: C# user control as a custom panel
body: <p>I create my own user control which only contains a panel :</p>
  
  <p>When I drag a myPanel object in the designer and then try to add a button on it, the button is in fact added to the form's controls.</p>
  
  <p>Is there a property/attribute I must set in order to perform this, an other way to do what I want ?</p>
  
  <pre><code>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);
      }
  }
  </code></pre>