C#
  Home arrow C# arrow Coding Skills for a Windows Form Applicati...
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? 
C#

Coding Skills for a Windows Form Application
By: Murach Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 9
    2006-06-29

    Table of Contents:
  • Coding Skills for a Windows Form Application
  • How to code with a readable style
  • How to code comments
  • How to work with the Text Editor toolbar
  • How to use code snippets

  • 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


    Coding Skills for a Windows Form Application


    (Page 1 of 5 )

    If you want to learn how to code and test a Windows form application, look no further. This article, the second of three parts, helps you brush up your coding skills. It is excerpted from chapter three of the book Murach's C# 2005, written by Joel Murach (Murach, 2005; ISBN: 9781890774370).

    How to detect and correct syntax errors
     
    As you enter code, Visual Studio checks the syntax of each statement. If a syntax error, or build error, is detected, Visual Studio displays a wavy line under the code in the Code Editor. In the Code Editor in figure 3-6, for example, you can see the lines under txtPercent and txtAmount.

    If you place the mouse pointer over the code in error, a brief description of the error is displayed. In this case, the error message indicates that the name does not exist. That’s because the names entered in the Code Editor don’t match the names used by the Form Designer. If the names are correct in the Form Designer, you can easily correct these errors, by editing the names in the Code Editor. In this figure, for example, the names of the text boxes should be txtDiscountPercent and txtDiscountAmount.

    If the Error List window is open as shown in this figure, any errors that Visual Studio detects will also be displayed in that window. If the Error List window isn’t open, you can display it by pointing to the Error List tab that’s displayed on the lower edge of Visual Studio. Then, you can jump to the error in the Code Editor by double-clicking on it in the Error List window.

    When you’re first getting started with C#, you will inevitably encounter a lot of errors. As a result, you may want to use the Auto Hide button that’s available from the Error List window to keep it open all the time. This makes it easy to see errors as soon as they occur. Then, once you get the hang of working with C#, you can conserve screen space by using the Auto Hide button so this window is only displayed when you point to the Error List tab.

    By the way, Visual Studio isn’t able to detect all syntax errors as you enter code. Instead, some syntax errors aren’t detected until the project is built. You’ll learn more about building projects later in this chapter.

    The Code Editor and Error List windows with syntax errors displayed


    Figure 3-6.  How to detect and correct systax errors

    Description

    • Visual Studio checks the syntax of your C# code as you enter it. If a syntax error (or build error) is detected, it’s highlighted with a wavy underline in the Code Editor, and you can place the mouse pointer over it to display a description of the error.
    • If the Error List window is open, all of the build errors are listed in that window. Then, you can double-click on any error in the list to take you to its location in the Code Editor. When you correct the error, it’s removed from the error list.
    • If the Error List window isn’t open, you can display it by selecting the Error List command from the View menu. Then, you can click the Error List tab that’s displayed at the edge of the Visual Studio window. If you prefer, you can click its Auto Hide button to keep it displayed.
    • Visual Studio doesn’t detect some syntax errors until the project is built. As a result, you may encounter more syntax errors when you build and run the project.

    More coding skills
     
    At this point, you should understand the mechanics of adding code to a form. To code effectively, however, you’ll need some additional skills. The topics that follow present some of the most useful coding skills.

    More C# Articles
    More By Murach Publishing


       · This article is an excerpt from the book "Murach's C# 2005," published by Murach. We...
     

    Buy this book now. This article is excerpted from chapter three of the book Murach's C# 2005, written by Joel Murach (Murach, 2005; ISBN: 9781890774370). Check it out today at your favorite bookstore. Buy this book now.

    C# ARTICLES

    - Coding a CRC-Generating Algorithm in C
    - Cyclic Redundancy Check
    - Handling Methods and Functions
    - Destroying Objects in C#
    - Creating Objects in C-Sharp
    - Classes and Objects
    - Programming Languages: Managed versus Native
    - LINQ-to-MySQL with DbLinq in C#
    - Working with Dates and Times in C#
    - Generics, Dictionaries, and More
    - More About Generics
    - Working with C# Collections
    - Generics
    - C# and XML
    - Pointers and Arrays in C#





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