Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 3 - 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 design a form


    (Page 3 of 5 )

    When you create a new project, the project begins with a single, blank form. You can then add controls to this form and set the properties of the form and controls so they look and work the way you want.

    The design of the Invoice Total form

    Before I show you how to add controls to a form and set the properties of the form and controls, I want to describe the Invoice Total form that I’ll use as an example throughout this chapter and the next chapter. This form is presented in figure 2-3. As you can see, the form consists of ten controls: four text boxes, four labels, and two buttons.

    The Invoice Total form lets the user enter a subtotal into the text box, and then calculates the discount percent, discount amount, and total for that order when the user clicks the Calculate button. For this simple application, the discount percent is based upon the amount of the subtotal, and the results of the calculation are displayed in read-only text box controls.

    After the results of the calculation are displayed, the user can enter a different subtotal and click the Calculate button again to perform another calculation. This cycle continues until the user clicks the Close button in the upper right corner of the form or clicks the Exit button. Then, the form is closed and the application ends.

    This application also provides keystroke options for users who prefer using the keyboard to the mouse. In particular, the user can activate the Calculate button by pressing the Enter key and the Exit button by pressing the Esc key. The user can also activate the Calculate button by pressing Alt+C and the Exit button by pressing Alt+X.

    In the early days of computing, it was a common practice to sketch the user interface for an application on paper before developing the application. That’s because a programmer had to enter the code that defined the user interface, and the task of writing this code would have been error prone if the interface wasn’t planned out first. As you’ll see in this chapter, however, the Form Designer makes it easy to design a form at the same time that you implement it. Because of that, you usually don’t need to sketch the layout of a form before you design it in Visual Studio.

    As you use the Form Designer, Visual Studio automatically generates the Visual Basic code that’s needed to define the form and its controls. In other words, the form that you see in the Form Designer is just a visual representation of the form that the Visual Basic code is going to display later on. Then, all you have to do is write the Visual Basic code that gives the form its functionality, and you’ll learn how to do that in the next chapter.

    The Invoice Total form

    Description

    1. A text box is used to get the subtotal from the user. Read-only text boxes are used to display the discount percent, discount amount, and total. And label controls are used to identify the values that are in the text boxes on the form.
    2. After entering a subtotal, the user can click the Calculate button to calculate the discount percent, discount amount, and total. Alternatively, the user can press the Enter key to perform the calculation. 
       
    3. To calculate another invoice total, the user can enter another subtotal and then click the Calculate button or press the Enter key again. 
       
    4. To close the form and end the application, the user can click the Close button in the upper right corner of the form or click the Exit button. Alternatively, the user can press the Esc key to exit from the form. 
       
    5. The user can press Alt+C to access the Calculate button or Alt+X to access the Exit button. On most systems, the letters that provide the access to these buttons aren’t underlined until the user presses the Alt key.

    Three types of controls

    • A label displays text on a form.
    • A text box lets the user enter text on a form. 
       
    • A button initiates form processing when clicked. 
       

    Figure 2-3.  The design of the Invoice Total 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 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek