Microsoft Visual C# - Lesson 1: Introduction to Applications
Home

Introduction to Microsoft Visual C#

 

Microsoft Visual C# Fundamentals

 

Introduction

Microsoft Visual C# is a programming environment used to create graphical user interface (GUI) applications for the Microsoft Windows family of operating systems. It usually ships in two types, either by itself or as part of Microsoft Visual Studio .NET. To use the lessons on this site, you must have installed either Microsoft Visual C# .NET 2003 or Microsoft Visual Studio .NET 2003. All instructions on this site will be based on an installation of Microsoft Visual Studio .NET 2003. From now on, unless specified otherwise, we will use the expressions "Microsoft Visual C#" or "Visual C#" to refer to Microsoft Visual C# .NET 2003.

After installing Microsoft Visual Studio .NET 2003, to use the programming environment, you must first open it. To do that, you would click Start -> (All) Programs -> Microsoft Visual Studio .NET 2003 -> Microsoft Visual Studio .NET 2003.

 

Practical LearningPractical Learning: Launching Microsoft Visual C#

 

The Integrated Development Environment: The Title Bar

After Microsoft Visual Studio has been opened, the screen you look at is called an Integrated Development Environment or IDE. The IDE is the set of tools you use to create a program.

The system icon System Icon is used to identify the application that you are using. Almost every application has its own system icon. The system icon holds its own list of actions; for example, it can be used to move, minimize, maximize or close (when double-clicked) a window.

When you freshly start Visual Studio, the main section of the title bar displays the name of the application as Microsoft Developer Environment. Later on, if you start a project, the title bar would display the name of your project, followed by the name of the programming environment you selected.

The main section of the title bar is also used to move, minimize, maximize the top section of the IDE, or to close Visual Studio. On the right section of the title bar, there are three system buttons with the following roles:

Button Role
Minimizes the window
Maximizes the window
Restores the window
Closes the window
 

The Integrated Development Environment: The Main Menu

Under the title bar, there is a range of words located on a gray bar. This is called the menu or main menu. In our lessons, the expression “Main Menu” refers to the menu on top of the IDE. To use a menu, you click one of its words and the menu expands. If an item is missing from the main menu, you can customize it. There are four main types of menus you will encounter.

When clicked, the behavior of a menu that stands alone depends on the actions prior to clicking it. Under the File menu, examples include Close, Save All, or Exit. For example, if you click Close, Microsoft Visual Studio will find out whether the current file had been saved already. If it has been, the file would be closed; otherwise, you would be asked whether you want to save it before closing it.

A menu that is disabled is not accessible at the moment. This kind of menu depends on another action or the availability of something else.

A menu with three dots means that an intermediary action is required in order to apply its assigned behavior. Usually, this menu would call a dialog box where the user would have to make a decision.

A menu with an arrow holds a list of menu items under it. A menu under another menu is called a submenu. To use such a menu, you would position the mouse on it to display its submenu.

Notice that, on the main menu (and any menu), there is one letter underlined on each word. Examples are F in File, E in Edit, V in View, etc. The underlined letter is called an access key. It allows you to access the same menu item using the keyboard. In order to use an access key, the menu should have focus first. The menu is given focus by pressing either the Alt or the F10 keys.

On some menu items, there is a key or a combination of keys we call a shortcut. This key or this combination allows you to perform the same action on that menu using the keyboard.
If the shortcut is made of one key only, you can just press it. If the shortcut is made of two keys, press and hold the first one, while you are holding the first, press the second key once and release the first key. Some shortcuts are a combination of three keys.

From now on, in this book,

Press Means
T Press the T key
Alt, G Press and release Alt. Then press G
Ctrl + H Press and hold Ctrl. While you are still holding Ctrl, press H once. Then release Ctrl
Ctrl + Shift + E Press and hold Ctrl. Then press and hold Shift. Then press E once. Release Ctrl and Shift
 

Practical LearningPractical Learning: Using the Main Menu

  1. On the main menu, click File -> New -> Project...
  2. In the Project Types tree list of the New Project dialog box, click the Visual C# Projects node 
  3. In the Templates list, click Windows Application
  4. In the Name edit box, type Exercise1
  5. In the  Location text box, type C:\Programs\MSVCS unless you are not allowed to create that directory for any reason. In that case, use any directory
     
    New Project
  6. Click OK
    This creates a new project
 

The Toolbars

A toolbar is an object made of buttons. These buttons provide the same features you would get from the (main) menu, only faster. Under the main menu, the IDE is equipped with an object called the Standard toolbar. For example, to create a new project, on the main menu, you could click File -> New -> Project… On the other hand, the Standard toolbar is equipped with a button to perform the same action a little faster:

New Project

By default, the Standard toolbar is positioned under the main menu but you can position it anywhere else on the IDE. To move a toolbar, position the mouse on the dotted line on its left section. The mouse pointer will change into a cross:

Then click and drag away from that position:

In the same way, you can position the toolbar anywhere on the screen. You can also attach or "dock" it to one of the four sides of the IDE. When a toolbar is not docked to one side of the IDE, it is said to float. When a toolbar is floating, you can resize it by dragging one of its borders. If a toolbar is floating, to put it back to its previous position, you can double-click its title bar.

By default, when you start Visual Studio, it is equipped with one one toolbar: Standard. To get more toolbars, on the main menu, you can click View -> Toolbars and click the toolbar of your choice. You can also right-click any available toolbar or the main menu. This displays a list of all the available toolbars. Those that are currently opened have a check mark next to them. You can get a list of the toolbars that are available if you right-click any button on any toolbar or menu. On this site, every toolbar is referred to by its name.

A toolbar is equipped with buttons that could be unfamiliar. Just looking at one is not obvious. To know what a button is used for, you can position the mouse on top of it. A tool tip will come up and display for a few seconds.

From now on, each button on any toolbar will be named after its tool tip. This means that, if a tool tip displays "Hungry", its button will be called the Hungry button. If a tool tip displays "Exercises and Assignments", its button will be called the Exercises and Assignments button. If you are asked to click a button, position your mouse on different buttons until one displays the referred to name.

Some buttons present an arrow on their right side. This arrow represents a menu.

Like the menu, the toolbars can be customized.

 

Practical LearningPractical Learning: Customizing a Toolbar

  1. To customize the Standard toolbar by adding buttons to it, right-click anything on the main menu or the toolbar and click Customize...
  2. On the Customize dialog box, click the Commands tab
  3. In the Categories list, click Debug
  4. In the Commands list, click and drag Start Without Debugging
  5. Position it somewhere in the Standard toolbar:
     
    Customizing the Standard Toolbox
  6. Release the mouse
  7. Click the Close button on the Customize dialog box
 

Projects Fundamentals

 

Creating a Project

This lessons assumes that you already know a good deal of the C# language, but only the language. We assume that you have no prior knowledge of graphical application programming. In our lessons, we will create Windows applications, the type referred to a graphical user interface (GUI).

To create a Visual C# project, you can display the New Project dialog box, select Visual C# Projects, select the type of project, give it a name, specify its directory, and click OK.

 

Compiling and Executing a Project

As mentioned already, the instructions created for a Visual Basic project are written in plain English in a language easily recognizable to the human eye. To compile and execute a Visual Basic .NET project in one step, on the main menu, you can click Debug -> Start Without Debugging. Although there are other techniques or details in compiling (or debugging) and executing a project, for now, this is the only technique we will use until further notice.

 

Practical LearningPractical Learning: Executing a Project

  1. To execute the application, on the main menu, click Build -> Build Solution

  2. To execute the application, on the Standard toolbar, click the Start button

  3. After viewing the application, close it

 

Opening a Project

As opposed to creating a new project, you can open a project that either you or someone else created. To open an existing project, on the main menu, you can click File -> Open -> Project... You can also click File -> Open Solution on the main menu. Alternatively, you can display the Start Page and click Open Open. In all cases, the action would display the Open Project dialog box. This allows you to select a Visual Project and open it.

 

Copyright © 2004-2014 FunctionX, Inc. Next