Mega Code Archive

 
Categories / C# Tutorial / GUI Windows Forms
 

Dock to four directions and fill

using System; using System.Windows.Forms;  namespace MyApp   {    class DockingForm : Form {   public DockingForm()   {     this.Text = "Docking Windows Forms Application";     Button topButton = new Button();     topButton.Text = "Top";     Button leftButton = new Button();     leftButton.Text = "Left";     Button rightButton = new Button();     rightButton.Text = "Right";     Button bottomButton = new Button();     bottomButton.Text = "Bottom";     Button fillButton = new Button();     fillButton.Text = "Fill";     Controls.Add(topButton);     Controls.Add(leftButton);     Controls.Add(rightButton);     Controls.Add(bottomButton);     Controls.Add(fillButton);     topButton.Dock = DockStyle.Top;     leftButton.Dock = DockStyle.Left;     rightButton.Dock = DockStyle.Right;     bottomButton.Dock = DockStyle.Bottom;     fillButton.Dock = DockStyle.Fill;   }   public static void Main()    {     DockingForm df = new DockingForm();     Application.Run(df);   }      }  }