Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 4 - How to Design a Windows Forms Application
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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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

How to Design a Windows Forms Application
By: Murach Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating:  stars stars stars stars stars / 0
    2009-07-06

    Table of Contents:
  • How to Design a Windows Forms Application
  • How to create a new project
  • How to design a form
  • How to add controls to a form
  • How to set properties

  • 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
     
     
    ADVERTISEMENT


    How to Design a Windows Forms Application - How to add controls to a form


    (Page 4 of 5 )

    Figure 2-4 shows how you can use the Toolbox to add controls to a form. The easiest way to do that is to click on the control in the Toolbox, then click the form at the location where you want to add the control. In this figure, for example, the button control is selected in the Toolbox, and the mouse pointer is positioned over the form.

    Once you add a control to a form, you can resize the control by selecting it and dragging one of its handles, and you can move the control by dragging the control to a new location on the form. If you prefer, you can place and size the control in a single operation by clicking the control in the Toolbox, then clicking and dragging in the form.

    A second way to add a control is to drag the control from the Toolbox to the form. The control is placed wherever you drop it. You can then resize the control.

    A third method for adding controls is to double-click the control you want to add in the Toolbox. This places the control in the upper left corner of the form. You can then move and resize the control.

    If the AutoHide feature is activated for the Toolbox and you move the mouse pointer over the Toolbox tab to display it, the display frequently obscures some or all of the form. This makes it difficult to add controls. As a result, it’s a good idea to turn off the AutoHide feature when you’re adding controls. To do that, just click the pushpin button in the upper right corner of the Toolbox.

    After you have added controls to the form, you can work with several controls at once. For example, let’s say that you have four text box controls on your form and you want to make them all the same size with the same alignment. To do that, first select all four controls by holding down the Ctrl or Shift key as you click on them or by using the mouse pointer to drag a dotted rectangular line around the controls. Then, use the commands in the Format menu or the buttons in the Layout toolbar to move, size, and align the controls relative the primary control. If you select the controls one at a time, the primary control will be the first control you select. If you select the controls by dragging around them, the primary control will be the last control in the group. To change the primary control, just click on it. (The primary control will have different color handles so you can identify it.)

    Although these techniques may be hard to visualize as you read about them, you’ll find that they’re relatively easy to use. All you need is a little practice, which you’ll get in the exercise for this chapter.

    A Form after some controls have been added to it

    Three ways to add a control to a form

    1. Select the control in the Toolbox. Then, click in the form where you want to place the control. Or, drag the pointer on the form to place the control and size it at the same time.
    2. Double-click the control in the Toolbox. Then, the control is placed in the upper left corner of the form. 
       
    3. Drag the control from the Toolbox and drop it on the form. Then, the control is placed wherever you drop it.

    How to select and work with controls

    • To select a control on the form, click it. To move a control, drag it.
    • To size a selected control, drag one of its handles. Note, however, that a label is sized automatically based on the amount of text that it contains. As a result, you can’t size a label by dragging its handles unless you change its AutoSize property. 
       
    • To select more than one control, hold down the Shift or Ctrl key as you click on each control. You can also select a group of controls by clicking on a blank spot in the form and then dragging around the controls. 
       
    • To align, size, or space a group of selected controls, click on a control to make it the primary control. Then, use the commands in the Format menu or the buttons on the Layout toolbar to align, size, or space the controls relative to the primary control. 
       
    • You can also size all of the controls in a group by sizing the primary control in the group. And you can drag any of the selected controls to move all the controls. 
       
    • To change the size of a form, click the form and drag one of its sizing handles.  

     

    Figure 2-4.  How to add controls to a form

    More Visual Basic.NET Articles
    More By Murach Publishing


     

    Buy this book now. This article is excerpted from chapter two of Murach's Visual Basic 2008, written by Anne Boehm (Murach, 2008; ISBN: 1890774456). Check it out today at your favorite bookstore. Buy this book now.

    VISUAL BASIC.NET ARTICLES

    - User-defined Functions using Visual Basic Ap...
    - Understanding Object Binding in VBA
    - Mastering the Message Box
    - Testing a Windows Forms Application
    - Using Visual Basic.NET Features to Code a Wi...
    - Correcting Code in a Windows Forms Applicati...
    - Write Readable Code and Comments for Windows...
    - How to Code and Test a Windows Forms Applica...
    - Adding Features to a Windows Forms Applicati...
    - How to Design a Windows Forms Application
    - LINQ to XML Programming Using Visual Basic.N...
    - Understanding Delegates using Visual Basic.N...
    - Create a Sudoku Puzzle Generator using VB.NET
    - Entity Creation and Messaging in a VB.NET Te...
    - Movement and Player Statistics in a VB.NET T...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek