Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 2 - Manipulating Forms with the Windows Forms ...
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Manipulating Forms with the Windows Forms Library
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2007-02-22

    Table of Contents:
  • Manipulating Forms with the Windows Forms Library
  • 4.11 Attaching a Control to the Edge of a Form
  • 4.12 Moving or Resizing Controls as a Form Resizes
  • 4.13 Limiting the Sizing of a Form

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Manipulating Forms with the Windows Forms Library - 4.11 Attaching a Control to the Edge of a Form
    (Page 2 of 4 )

     Problem

    You want a specific control, such as a toolbar, to always “stick” to one edge of the form, no matter how it is resized.

    Solution

    Use the control’s Dock property to permanently affix the control to the selected side or other “dock region.”

    Discussion

    Dock has six possible values:

    None
      
    The control performs no docking.

    Top
       The control attaches itself to the top of the form’s
       client area and fills the entire width of the client area,
       if the control supports such resizing.

    Bottom 
     
    The control attaches itself to the bottom of the
        form’s client area and fills the entire width of the 
       client area, if the control supports such resizing.

    Left
       The control attaches itself to the left edge of the
       form’s client area and fills the entire height of the
       client area, if the control supports such resizing.

    Right 
     
    The control attaches itself to the right edge of the
       form’s client area and fills the entire height of the
       client area, if the control supports such resizing.

    Fill 
      
    The control fills the entire client area of the form, if
        the control supports such resizing.

    If multiple controls haveDocksettings other thanNone, they are attached to the form edges according to their z-order settings, starting from the back-most control. To alter the z-order of a control, right-click on the control in the Form Designer and select either “Bring to Front” or “Send to Back” from the shortcut menu. Figures 4-9 and 4-10 show a form with two controls with different z-orders docked to its bottom edge: aMonthCalendarcontrol (notice how it automatically fills the width of the form by adding months) and aStatusStrip control.


    Figure 4-9.  The form when the calendar's z-order is in front

    Some controls are designed to dock along a specific edge of the form’s client area. The most obvious example is theStatusStrip control, shown in this recipe’s figures, which is designed to dock along the bottom edge of the form. Other controls, such as theCheckBoxcontrol, really aren’t designed for docking. While you can still dock them, they may not look very nice.

    Docking also applies to panels and other containers that can include subordinate controls. Figure 4-11 displays aPanelcontrol with an includedComboBox control that is docked along the top edge of the panel.

    Attaching a Control to the Edge of a Form


    Figure 4-10.  The form when the calendar's z-order is in back


    Figure 4-11.  Docking within a container

    See Also

    Recipe 4.12 discusses the Anchor property, which can be used to attach a control to one, two, three, or four sides of the form. The Dock andAnchorproperties cannot be used at the same time on the same control. The last one you set on that control is the one used.

    More Visual Basic.NET Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Visual Basic 2005 Cookbook," published by...
     

    Buy this book now. This article is excerpted from chapter four of the Visual Basic 2005 Cookbook, written by Tim Patrick and John Clark Craig (O'Reilly; ISBN: 0596101775). Check it out today at your favorite bookstore. Buy this book now.

    VISUAL BASIC.NET ARTICLES

    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...
    - Programmatically Controlling Windows Fax Ser...
    - Focusing on Forms and Menus in Visual Basic
    - Manipulating Forms with the Windows Forms Li...
    - Basics of the Windows Forms Library
    - Forms, Controls, and Other Useful Objects
    - Implementing OOP to Develop Database Oriente...
    - Using Themes and Skins for Personalization w...
    - A Deeper Look at Personalization using Visua...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway