Dock to four directions and fill : Dock « GUI Windows Forms « C# / CSharp Tutorial






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);
  }  
   }
 }








23.58.Dock
23.58.1.Dock Top and BottomDock Top and Bottom
23.58.2.All DockStyles illustration
23.58.3.Dock to four directions and fill