C#
  Home arrow C# arrow Page 5 - 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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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 - How to use code snippets


    (Page 5 of 5 )


     
    When you add code to an application, you will often find yourself entering the same pattern of code over and over. For example, you often enter a series of if blocks like the ones in the previous figures. To make it easy to enter patterns like these, though, Visual Studio 2005 introduces a new feature known as code snippets. These code snippets make it easy to enter common control structures like the ones that you’ll learn about in chapter 5.

    Sometimes, you’ll want to insert a code snippet on a blank line of text as shown in figure 3-10. In that case, you can right-click on the blank line in the Code Editor and select the Code Snippet command from the resulting menu. Then, you can select the shortcut name for the code snippet you wish to insert and press the Tab key. When you do, the code snippet will be inserted into the Code Editor. In this figure, for example, the code snippet named if (not the #if snippet at the top of the list) has been inserted into the document. This snippet contains the start of an if block. Now, you just need to enter a condition within the parentheses and some statements for the if block between the curled braces.

    Other times, you’ll want to surround existing lines of code with a code snippet. In that case, you can select the code that you want to surround, right-click on that code, and select the Surround With command from the resulting menu. Then, you can select the appropriate snippet. For example, you might want to add an if block around one or more existing statements.

    If you find that you like using code snippets, you should be aware that it’s possible to add or remove snippets from the default list. To do that, you can choose the Code Snippets Manager command from the Tools menu. Then, you can use the resulting dialog box to remove code snippets that you don’t use or to add new code snippets. Be aware, however, that writing a new code snippet requires creating an XML file that defines the code snippet. To learn how to do that, you can consult the documentation for Visual Studio.

    Incidentally, if you’re new to programming and don’t understand the if statements in this chapter, don’t worry about that. Instead, just focus on the mechanics of using code snippets. In chapter 5, you’ll learn everything you need to know about coding if statements.

    The default list of code snippets


    Figure 3-10.  How to use code snippets

    A code snippet after it has been inserted

    Description

    1. To insert a code snippet, right-click in the Code Editor and select the Code Snippet command from the resulting menu. Then, select the code snippet you wish to insert.
    2. To surround existing code with a code snippet, select the code, right-click on it, and select the Surround With command from the resulting menu. Then, select the appropriate snippet.
    3. You can use the Tools->Code Snippets Manager command to display a dialog box that you can use to edit the list of available code snippets and to add custom code snippets.

    Please check back next week for the conclusion of this article.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · 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

    - C# and XML
    - Pointers and Arrays in C#
    - C# 3.0 Extension Methods
    - Overloading Operators in C#
    - Iterators and Nullable Types
    - Patterns and Iterators in C#
    - C# Exceptions
    - Methods in C#
    - Delegates and Events in C#
    - Advanced C#
    - Working with Regular Expressions in C#
    - Sending Simple E-Mail in C#
    - Building C# Comparable Objects: IComparable ...
    - Color Transformation Applications in C# GDI+...
    - Performing Color Transformation Operations i...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT