spacer
Yehuda Shiran September 4, 2002
Creating Docking Windows
Tips: September 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Mozilla's Ubquity Mashup: For The Masses?
iPhone Users Just Want to Have Fun
Oops! I Fixed the Linux Kernel
Many applications build their user interfaces with dockable windows. The advantage of dockable windows is that you can control the size of each window, while the container window prevents them from cluttering each other. You can achieve the effect of docking using either the Dock or Anchor property of the Panel class.

Let's look at an example where we use a Windows form to create three dockable panels on the bottom, top, and left sides of the container panel. Here is the definition of the container panel:

  basePanel= new Panel;
  basePanel.Location= new Point(0,0);
  basePanel.Size= new System.Drawing.Size(500,300);
  basePanel.Name= "basePanel";
  basePanel.Anchor= AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
Here is the definition of the left panel. It is docked with the Dock property, and it also has a 3D-style border:

  leftPanel= new Panel;
  leftPanel.Location= new Point(0,0);
  leftPanel.Size= new System.Drawing.Size(100,300);
  leftPanel.Name= "leftPanel";
  leftPanel.Dock= DockStyle.Left;
  leftPanel.BorderStyle = "Fixed3D";
We define the top panel in a similar way, using the Anchor property for docking:

  topPanel= new Panel;
  topPanel.Location= new Point(100,0);
  topPanel.Size= new System.Drawing.Size(400,200);
  topPanel.Name= "topPanel";
  topPanel.Anchor= AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
  topPanel.BorderStyle = "Fixed3D";
We define the third panel as follows:

  bottomPanel= new Panel;
  bottomPanel.Location= new Point(100,200);
  bottomPanel.Size= new System.Drawing.Size(400,100);
  bottomPanel.Name= "bottomPanel";
  bottomPanel.Anchor= AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
  bottomPanel.BorderStyle = "Fixed3D";
We need to add the three panels to the base panel:

  basePanel.Controls.Add(topPanel);
  basePanel.Controls.Add(bottomPanel);
  basePanel.Controls.Add(leftPanel);
To learn more about JScript .NET and ASP.NET, go to Column 117, JScript .NET, Part XI: Creating Windows Forms.


People who read this tip also read these tips:

Look for similar tips by subject:



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Performance Optimizations for High Speed JavaScript · Advanced Web Performance Optimization · Simple Comments Meets OpenID
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Extending Telephony: VoIP Call Recording for Business · U-Verse for Business Has Wi-Fi Perks · Lian-Li Launches New Power Supply Line, Rack Mount Kit and Fan Blower