Introduction to the Visual C# 2005 Express Edition IDE

62
2006 Pearson Education, Inc. All rights rese 1 2 Introduction to the Visual C# 2005 Express Edition IDE

description

2. Introduction to the Visual C# 2005 Express Edition IDE . Form ever follows function. Louis Henri Sullivan . Seeing is believing. Proverb . Intelligence …is the faculty of making artificial objects, especially tools to make tools. Henri-Louis Bergson. OBJECTIVES. - PowerPoint PPT Presentation

Transcript of Introduction to the Visual C# 2005 Express Edition IDE

Page 1: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

1

2Introduction to the

Visual C# 2005 Express Edition

IDE

Page 2: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

2

Form ever follows function.— Louis Henri Sullivan

Seeing is believing.— Proverb

Intelligence …is the faculty of making artificial objects, especially tools to make tools.

— Henri-Louis Bergson

Page 3: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

3

OBJECTIVESIn this chapter you will learn: The basics of the Visual Studio Integrated Development

Environment (IDE) that assists you in writing, running and debugging your Visual C# programs.

Visual Studio's help features. Key commands contained in the IDE's menus and

toolbars. The purpose of the various kinds of windows in the Visual

Studio 2005 IDE. What visual programming is and how it simplifies and

speeds program development. To create, compile and execute a simple Visual C#

program that displays text and an image using the Visual Studio IDE and the technique of visual programming.

Page 4: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

4

2.1 Introduction2.2 Overview of the Visual Studio 2005 IDE2.3 Menu Bar and Toolbar2.4 Navigating the Visual Studio 2005 IDE

2.4.1 Solution Explorer 2.4.2 Toolbox 2.4.3 Properties Window

2.5 Using Help2.6 Using Visual Programming to Create a Simple

Program Displaying Text and an Image2.7 Wrap-Up2.8 Web Resources

Page 5: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

5

2.1 Introduction

• Visual Studio 2005─ Microsoft Integrate Development Environment (IDE)

• Create, run, and debug programs

• Visual Programming ─ Create program by dragging and dropping predefined

building blocks into place

Page 6: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

6

2.2 Overview of the Visual Studio 2005 IDE

• Microsoft Visual C# Express Edition ─ Only support Visual C# programming language

• Start page (Fig. 2.1)─ A list of links to resources in the IDE and on the internet

• Visual C# Express Headlines and MSDN (Fig. 2.2)─ This section provides links to information about programming in C#

• Note: MSDN stands for Microsoft Developer Network

Page 7: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

7

Hiddenwindow

Start Page links Empty SolutionExplorer (noprojects open)

New Project button

Start Page tab

Fig. 2.1 | Start Page in Visual C# 2005 Express Edition.

Page 8: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

8Requested Web page(URL in location bardrop-down menu)

Selected tab requested Web page

Fig. 2.2 | Displaying a Web page in Visual Studio.

Page 9: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

9

2.2 Overview of the Visual Studio 2005 IDE (cont.)• Creating a New Project

─ New Project Dialog (Fig. 2.3)• Dialog to choose type of program to build

─ Windows Form Designer (Fig. 2.4)• Design portion of IDE

─ Properties• Change a component of the program (Fig. 2.5)

─ Buttons • Confirm action, change and etc. (Fig. 2.6)

Page 10: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

10

Visual C# WindowsApplication (selected)

Default project name(provided by Visual Studio)

Description of selected projecttemplate (provided by Visual Studio)

Fig. 2.3 | New Project dialog.

Page 11: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

11

Active tab Tabs Menu Menu barSolution Explorerwindow

Form (Windows application) Properties window

Fig. 2.4 | Design view of the IDE.

Page 12: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

12

Text box (displayingthe text Form1), whichcan be modified.

Fig. 2.5 | Example of a text box control in the Visual Studio IDE.

Page 13: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

13

OK button

Cancel button

Fig. 2.6 | Examples of buttons in the Visual Studio IDE.

Page 14: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

14

2.3 Menu Bar and Toolbar

• Menu Bar (Fig. 2.7)─ The bar of where the commands for managing the IDE

and for developing, maintaining and executing programs are located

• Tool Bar (Fig. 2.9)─ The bar of where the more common commands are located

• Tool Tip (Fig. 2.12)─ Description of a icon

Page 15: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

15

Fig. 2.7 | Visual Studio menu bar.

Page 16: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

16

Menu Description

File Contains commands for opening, closing, adding and saving projects, as well as printing project data and exiting Visual Studio.

Edit Contains commands for editing programs, such as cut, copy, paste, undo, redo, delete, find and select.

View Contains commands for displaying windows (e.g., Solution Explorer, Toolbox, Properties window) and for adding toolbars to the IDE.

Project Contains commands for managing projects and their files.

Build Contains commands for compiling a program.

Debug Contains commands for debugging (i.e., identifying and correcting problems in a program) and running a program. Debugging is discussed in detail in Appendix C.

Data Contains commands for interacting with databases (i.e., organized collections of data stored on computers), which we discuss in Chapter 20, Database, SQL and ADO.NET).

Format Contains commands for arranging and modifying a form’s controls. Note that the Format menu appears only when a GUI component is selected in Design view.

Fig. 2.8 | Summary of Visual Studio 2005 IDE menus (Part 1 of 2).

Page 17: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

17

Menu Description

Tools Contains commands for accessing additional IDE tools (e.g., the Toolbox) and options that enable you to customize the IDE.

Window Contains commands for arranging and displaying windows.

Community Contains commands for sending questions directly to Microsoft, checking question status, sending feedback on Visual C# and searching the CodeZone developer center and the Microsoft developers community site.

Help Contains commands for accessing the IDE’s help features.

Fig. 2.8 | Summary of Visual Studio 2005 IDE menus (Part 2 of 2).

Page 18: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

18

Save

Other Windows

Solution Configurations

New project Open File Save All Copy Undo

Navigate backwards Start

Add Item Cut Paste Redo Navigate

forwards

Solution Platforms

Find in files

Solution Explorer

Object browser

Start Page

FindProperties Window

Toolbox Window

a)

b)

Fig. 2.9 | Standard toolbar in Visual Studio.

Page 19: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

19Standard toolbar

Build toolbar added to the Standard toolbar

Fig. 2.10 | Adding the Build toolbar to the IDE.

Page 20: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

20

ToolbarDown arrow indicatesadditional commands

Fig. 2.11 | IDE toolbar icon showing additional commands.

Page 21: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

21

Tool tip displayed when the mouse pointerrests over the New Project icon

Fig. 2.12 | Tool tip demonstration.

Page 22: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

22

Solution Explorer Toolbox

Propertieswindow

Fig. 2.13 | Toolbar icons for three Visual Studio windows.

Page 23: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

23

2.4 Navigating the Visual Studio 2005 IDE• Auto-Hide (Fig. 2.14 – 2.16)

─ Space saving feature• Solution Explorer (Fig. 2.17 – 2.20)

─ Provides access to all of the files in a solution• Toolbox (Fig. 2.21)

─ Contains icons representing controls used to customize form

• Properties Window (Fig. 2.22)─ The window to change information about a form or

control

Page 24: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

24

Tab forhidden

window (auto-hide

enabled)

Fig. 2.14 | Auto-hide feature demonstration.

Page 25: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

25

Toolboxtitle bar

Horizontal orientation for

pin icon

Fig. 2.15 | Displaying a hidden window when auto-hide is enabled.

Page 26: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

26

Toolbox “pinned down”

Vertical orientation for pin icon

Fig. 2.16 | Disabling auto-hide (“pinning down” a window).

Page 27: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

27

Show all files icon

Toolbar

Startup project

Fig. 2.17 | Solution Explorer with an open project.

Page 28: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

28

Plus box

Minus box

Fig. 2.18 | Solution Explorer showing plus boxes and minus boxes for expanding and collapsing the tree to show or hide project files.

Page 29: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

29

Minus box indicates that the file of folder is

expanded (changed from plus box)

Fig. 2.19 | Solution Explorer expanding the Properties file after clicking its plus box.

Page 30: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

30

Plus boxes indicate that the file or folder is

collapsed (changed from minus box)

Fig. 2.20 | Solution Explorer collapsing all files after clicking any minus boxes.

Page 31: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

31

Group namesControls

Fig. 2.21 | Toolbox window displaying controls for the Common Controls group.

Page 32: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

32

Categorized icon

Alphabetical icon

Description of the Text property

Component selection drop-down list

Toolbar

Properties Properties values

Fig. 2.22 | Properties window displaying the Text property of the Form.

Page 33: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

33

2.5 Using Help

• Dynamic Help (Fig. 2.24)─ Excellent way to get information quickly about the IDE

and its features

• Context-Sensitive Help (Fig. 2.25)─ Immediately displays a relevant help article

Page 34: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

34

Command Description

How Do I Contains links to relevant topics, including how to upgrade programs and learn more about Web services, architecture and design, files and I/O, data, debugging and more.

Search Finds help articles based on search keywords.

Index Displays an alphabetized list of topics you can browse.

Contents Displays a categorized table of contents in which help articles are organized by topic.

Fig. 2.23 | Help menu commands.

Page 35: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

35

ContentsSelected Item How Do ISearch Index

Dynamic Help window

Relevant help articles on the selected item (e.g., the Form)

Fig. 2.24 | Dynamic Help window.

Page 36: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

36

Fig. 2.25 | Using context-sensitive help.

Page 37: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

37

Show all settings check box

Help options selected Show Help using: box

Fig. 2.26 | Options dialog displaying Help settings.

Page 38: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

38

2.6 Using Visual Programming to Create a Simple Program Displaying Text and an Image• Creating a Simple Program

─ Create the new project (Fig. 2.28-2.30)─ Set the text in in the form’s title bar (Fig. 2.31)─ Resize the form (Fig. 2.32-2.33)─ Change the form’s background color (Fig. 2.34-2.35)─ Add a Label control to the form (Fig. 2.36)─ Customize the label’s appearance (Fig. 2.37-2.38)─ Set the label’s font size (Fig. 2.39-2.40)

Page 39: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

39

2.6 Using Visual Programming to Create a Simple Program Displaying Text and an Image (Cont.)

• Creating a Simple Program (Cont.)─ Align the label’s text (Fig. 2.41)─ Add a PictureBox to the form (Fig. 2.42)─ Insert an image (Fig. 2.43-2.47)─ Save the project ─ Run the project (Fig. 2.47-2.49)─ Terminate execution

Page 40: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

40

Label control

PictureBoxcontrol

Fig. 2.27 | Simple program executing.

Page 41: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

41

Template types

Type in the project name

Fig. 2.28 | New Project dialog.

Page 42: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

42

Fig. 2.29 | Save Project dialog.

Page 43: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

43

Click to set project location

Selected Project location

Fig. 2.30 | Setting the project location in the Project Location dialog.

Page 44: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

44

Name and type of object

Property valueSelected property

Property description

Fig. 2.31 | Setting the form’s Text property in the Properties window.

Page 45: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

45

Enabled sizing handles

Title bar

Fig. 2.32 | Form with enabled sizing handles.

Page 46: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

46

Fig. 2.33 | Resized form.

Page 47: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

47

Down-arrow button

Current color

Custom palette

Light blue

Fig. 2.34 | Changing the form’s BackColor property.

Page 48: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

48

New background color

Fig. 2.35 | Form with new BackColor property applied.

Page 49: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

49

Label control

Fig. 2.36 | Adding a label to the form.

Page 50: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

50

AutoSize property

Fig. 2.37 | Changing the Label’s AutoSize property to False.

Page 51: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

51

Sizing handles Label centered with

updated Text property

Fig. 2.38 | GUI after the form and Label have been customized.

Page 52: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

52

Ellipsis button

Fig. 2.39 | Properties window displaying the Label’s properties.

Page 53: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

53

Current font

Font sample

Fig. 2.40 | Font dialog for selecting fonts, styles and sizes.

Page 54: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

54

Fig. 2.41 | Centering the Label’s text.

Text alignment options

Middle-center alignment option

Page 55: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

55

UpdatedLabel

PictureBox

Fig. 2.42 | Inserting and aligning a PictureBox.

Page 56: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

56

Image property value(no image selected)

Fig. 2.43 | Image property of the PictureBox.

Page 57: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

57

Fig. 2.44 | Select Resource dialog to select an image for the PictureBox.

Page 58: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

58

Image file name

Fig. 2.45 | Select Resource dialog displaying a preview of selected image.

Page 59: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

59

SizeMode property set to StretchImageSizeMode property

Fig. 2.46 | Scaling an image to the size of the PictureBox.

Page 60: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

60

NewlyInserted image

Fig. 2.47 | PictureBox displaying an image.

Page 61: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

61Build menu

Fig. 2.48 | Building a solution.

Page 62: Introduction to the Visual C# 2005 Express Edition IDE

2006 Pearson Education, Inc. All rights reserved.

62

Form

Running program Close box

Fig. 2.49 | IDE in run mode, with the running program in the foreground window.