I am trying to insert several objects into a new form that I programmatically create; basically I want the Buttonbottom and RichTextBoxfill all the remaining space. I set the former as Dock = DockStyle.Bottom, and the latter as Dock = DockStyle.Fill, and it works.
Now I'm trying to insert a gap between the elements, so I added an addition in the form and a mark in the button. The first works correctly, but the margin is not, so between RichTextBoxand Buttonthere is no space.
Here is the code and output. Did I miss something?
SMSForm.Padding = new Padding(5);
RichTextBox SMStext = new RichTextBox();
SMSForm.Controls.Add(SMStext);
SMStext.Dock = DockStyle.Fill;
Button SMSsend = new Button();
SMSsend.Text = "Send SMS to ";
SMSForm.Controls.Add(SMSsend);
SMSsend.Margin = new Padding(10);
SMSsend.Dock = DockStyle.Bottom;

source
share