title: Drawing dynamic panels C#
body: <p>Good afternoon.
  There was a problem with the rendering of dynamically created panel, all panels initially were 100px and I their renders (y + = 100), but now the production has changed a bit, these panels can be of different sizes, and the distance between them actually remains unchanged 100rh ...</p>
  
  <p>Pliz tell me how to make, that they are somehow drawn at equal (10px) distances from each other. Read that you can somehow make a method SetBounds, but did not understand.</p>
  
  <p><a href="http://pastebin.com/TnSuFTti" rel="nofollow">http://pastebin.com/TnSuFTti</a></p>
  
  <pre><code>for (int i = data_list.Count - 1; i &gt;= 0; i--)
  {
      Panel panel = new Panel(); //создание блока сообщения и наложение картинки
      panel.Name = i.ToString();
      panel.MouseEnter += new EventHandler(panel_MouseEnter);
      Label textBox_name = new Label();
      Label textBox_date = new Label();
      Label textBox_msg = new Label();
      panel.Width = 308;
      Bitmap btm_msg = new Bitmap(
                  Properties.Resources.NotificationCenterWindow_msg_box);
      panel.BackgroundImage = btm_msg;
      panel.BackgroundImageLayout = ImageLayout.Stretch;
      panel.Location = new Point(5, 5);
  
      panel.Controls.Add(textBox_date); 
      textBox_date.Name = "textBox_date" + i.ToString();
      textBox_date.Location = new Point(232, 8);
      textBox_date.Size = new System.Drawing.Size(70, 15);
      textBox_date.BorderStyle = BorderStyle.None;
      textBox_date.MinimumSize = new System.Drawing.Size(72, 15);
      textBox_date.TextAlign = ContentAlignment.MiddleRight;
      textBox_date.BackColor = Color.DarkGray;
      textBox_date.Anchor = AnchorStyles.Right | AnchorStyles.Top;
      textBox_date.ForeColor = SystemColors.ScrollBar;
  
      panel.Controls.Add(textBox_name); 
      textBox_name.Size = new System.Drawing.Size(100, 15);
      textBox_name.MinimumSize = new System.Drawing.Size(100, 15);
      textBox_name.Location = new Point(5, 8);
      textBox_name.BorderStyle = BorderStyle.None;
      textBox_name.BackColor = Color.DarkGray;
      textBox_name.ForeColor = SystemColors.ScrollBar;
      panel.Height = textBox_name.Height + 19;
      panel1.Controls.Add(panel);
      panel.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
  
      y += 100;
  }
  </code></pre>