title: C# using dockstyle and set margin
body: <p>I'm trying to insert a couple of objects in a new form that I programmatically create; basically I want a <code>Button</code> on the bottom and a <code>RichTextBox</code> filling all the remaining space. I set the first as <code>Dock = DockStyle.Bottom</code> and the latter as <code>Dock = DockStyle.Fill</code> and it works.</p>
  
  <p>Now I'm trying to insert a spacing between elements, so I added a padding in the form and a margin in the button. The first works correctly, but margin doesn't, so no space between <code>RichTextBox</code> and <code>Button</code>.</p>
  
  <p>Here is the code and the output. Am I missing something?</p>
  
  <pre><code>// Parent Form
  SMSForm.Padding = new Padding(5);
  
  // TextBox
  RichTextBox SMStext = new RichTextBox();
  SMSForm.Controls.Add(SMStext);
  SMStext.Dock = DockStyle.Fill;
  
  // Button
  Button SMSsend = new Button();
  SMSsend.Text = "Send SMS to ";
  SMSForm.Controls.Add(SMSsend);
  SMSsend.Margin = new Padding(10);
  SMSsend.Dock = DockStyle.Bottom;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/jLWXk.png" alt="enter image description here"></p>