I'm trying to insert a couple of objects in a new form that I programmatically create; basically I want a Button
on the bottom and a RichTextBox
filling all the remaining space. I set the first as Dock = DockStyle.Bottom
and the latter as Dock = DockStyle.Fill
and it works.
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 RichTextBox
and Button
.
Here is the code and the output. Am I missing something?
// 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;
SuspendLayout
andResumeLayout
afterwards. – Inexactitude