Last Modified 5-1-2010




Introduction to C#

.NET Framework

VS2008 IDE

How C# is Compiled

Start Visual Studio

Windows Form App

C# OOP Coding

C# Code Example

C# Coding Rules


Error Window

C# Comments

C# Help Window

Language Essentials

C# Data Types

Declare Variables

Declare Constants

Arith. Expressions

Assign Statements

Operator Precedence

Type Casting

Math Class

C# Strings

String Esc Sequences

Convert Data Types

ToString Formatting

Variable Scope Use

C# Enumeration Use

C# Nullable Types

Program #2

C# Code Control

Relational Operators

Logical Operators

If-Else Statement

Switch Statement

Windows Forms Application Design Page 2

After the Common Controls Toolbox subsection is opened the Visual Studio Integrated Development Environment should appear as in the diagram below:

Select Toolbox

Figure CS-13: Visual C# Common Controls Toolbox Selecting TextBox Control

A Textbox Control needs to be placed on the Design Form in the approximate location indicated in Figure CS-13. The procedure for placing a control on the Design Form, which is located in the Toolbox is as follows:

  1. Position Mouse Pointer over the desired control in the Toolbox.
    • Windows will highlight the currently selectable control.
  2. Press and Hold the left mouse button once the desired control has been highlighted.
    • Windows will give a short description of the features of the control with a pop-up message.
    • In this case the messsage says: "Enables the user to enter text, ...
  3. Drag Control to the approximate location on the design form.
    • More precise positioning can be performed after the toolbox control is placed on the Design Form.
  4. Release Left Mouse Button to complete the initial control placement procedure.

Once the TextBox control is placed on the Design Form. We can facilitate placement of the remaining controls by locking the Toolbox menu in the Open Position by Left-Clicking on the Thumb Tack and having the needle point downward as illustrated in the diagram below:

Lock Toolbox

Figure CS-14: Lock Visual Studio Toolbox in Open Position

After locking the toolbox in the open position, repeat the procedure for 2 buttons, 4 labels and 3 more textboxes. The number of controls required and their location in the toolbox is illustrated in Figure CS-14. Repeat the procedure outlined above for placing controls on the design form until your form looks like the diagram illustrated below in Figure CS-15:

Invoice Guidelines

Figure CS-15: Invoice Total Form with Initial Placement of Controls

During placement of the controls, Visual Studio will assist you in the placement of your components by drawing vertical and horizontal guidelines on the screen to notify you when your controls are aligned with other controls allowing you to quickly line up your controls symmetrically.

Once your controls are placed on your Visual Studio Design Form as indicated in Figure CS-15, place the mouse pointer over the TextBox control and right-click your mouse to bring up the Control Options Dialog Box as indicated in Figure CS-16 below:

Control Dialog Box

Figure CS-16: Visual Studio Control Options Dialog Box

Move the mouse pointer to the Properties option of the Visual Studio Control Options Dialog Box and right-click to bring up the Visual Studio Control Properties window as indicated below in Figure CS-17:

Control Properties Window

Figure CS-17: Visual Studio Control Properties Window

When the Properties Window is displayed on your screen - change the Property Values on the right-side of the Properties window as illustrated above and described below:

  1. Left-Click on the current name of TextBox2 and change the value to txtDiscountPercent
  2. Left-Click on the TabStop property value of True to bring up option selector.
  3. Left-Click on the Option Selector and change the value to False.
  4. Left-Click on the ReadOnly Property and change value to True.

After changing the properties for TextBox2, perform the same procedure for all other controls and the Form using the Property values indicated below in Figure CS-18:

Invoice Total Form Properties

Figure CS-18: Visual Studio Invoice Total Control Properties

Make sure the Form Properties are set last as they use the new control properties for some of the values. In each subdivision the Properties are in alphabetical order. However, it is important to know under which subdivision each of the properties is located. The Form Subdivisions are addressed on page 3. Select Next to continue the Windows Form Application Tutorial: