You are on page 1of 19

Chapter 1

üIntroduction to the
Visual Studio 2005

INTRODUCTION

§ Included in Visual Studio.NET


Ÿ Visual Basic (VB.Net, VB 7.0)
Ÿ C++
Ÿ C# (đọc là C Sharp)
Ÿ J# (J Sharp)
Ÿ .NET Framework

CÀI ĐẶT Visual Studio.NET 2005

§ Chạy file setup.exe ta được hình minh họa (chú ý cài khá lâu có thể hơn 1 giờ)

3
CÀI ĐẶT Visual Studio.NET 2005

Nhấn
Next

CÀI ĐẶT Visual Studio.NET 2005

§ Thường các Key đã có sẵn

Nhấn Next

CÀI ĐẶT Visual Studio.NET 2005

Lựa chọn và yêu cầu phần khoảng trống ổ cứng

Chú ý

6
CÀI ĐẶT Visual Studio.NET 2005

•Cài đặt từng phần tốn khá


nhiều thời gian

CÀI ĐẶT MSDN (Help)

Cài đặt MSDN có thể độc lập hoặc cài sau khi đã cài bộ Visual
Studio 2005

CÀI ĐẶT MSDN (Help)

9
CÀI ĐẶT MSDN (Help)

10

CÀI ĐẶT MSDN (Help)

•Nên chọn full

11

CÀI ĐẶT MSDN (Help)

12
CÀI ĐẶT MSDN (Help)

13

CÀI ĐẶT MSDN (Help)

14

Introduction

§ Visual Studio .NET


Ÿ Framework.
Ÿ Microsoft’s Integrated Development Environment
(IDE)

15
The .NET Framework

§ The Common Language Runtime (CLR) is another


central part of the .NET Frameworkit executes .NET
programs
§ The .NET Framework Class Library (FCL) can be
used by any .NET language.

16

The .Net Framework

Understanding the .NET Framework Architecture

17

Understanding the Common Language


Runtime

Common Language Runtime Architecture

18
Programming Languages

§ Procedural
Ÿ Program specifies exact sequence
§ Event Driven
§ Object Oriented Programming (C#.NET)
Ÿ User controls sequence
Click event
Double Click event
Change event

19

Quá trình biên dịch và chạy một chương trình trên nền
.NET

C# C#
Code Compiler

Visual Basic VisualBasic JIT


Code IL
Compiler Compiler

COBOL COBOL Native


Code Compiler Code

20

Object Model

§ Object ==> Like a Noun in English


Ÿ Form and Controls on forms (Button, Text boxes…)
§ Property ==> Like Adjective,they describe object
Ÿ Text, Name, BackColor, Font and Size
§ Method ==> Like Verb, They are actions that objects exhibit
§ Event ==> Occur when the user takes action
Ÿ User clicks a button
§ Class ==> Template to create new object
Ÿ Each control added is an Instance of a Class (Example: adding a
second form to the project – it will have the same properties)
21
Dot Notation

§ Used to reference object's properties and methods in code


Ÿ Object dot Property
Form.Text, TextBox.Text
(Example: lblMessage.Text = "Hello World“)
Ÿ Object dot Method
Form.Hide( ), TextBox.Focus( )
§ To reference an object's events use an underscore instead of a dot
Button_Click, ListBox_TextChanged
private void btnHoLot_Click(object sender, EventArgs e)
{
// statement
}
22

INTRODUCTION

§ C#.NET supports programming projects that run in both


Windows desktop and Internet environments. We will
focus on the Windows desktop
§ Both of these environments are based on what is termed a
graphical user interface or GUI for short

23

Steps for Writing C#

§ Design/Define the User Interface


§ Plan/Set the Properties
§ Plan/Write the Code
§ Test and Debug

24
Visual Studio .NET Integrated Development
Environment (IDE) Overview

25

Visual Studio .NET Integrated Development


Environment (IDE) Overview

Visual C# Visual C# Windows


projects folder Application (selected)

project name

project location

26

IDE Main Window

§ Toolbars
§ Document Window
§ Form Designer
§ Solution Explorer
§ Properties Window
§ Toolbox

27
Visual Studio .NET Integrated Development
Environment (IDE) Overview

menu title bat

tabs
menu bar

active tab Solution


Explorer
Form
(windows
application)
Properties
window

28

Toolbox
toolbox group

§ Holds the tools


controls
you place on a
form

scroll arrow

29

Menu Bar and Toolbar

toolbar icon (indicates a command to open a file)

toolbar

down arrow indicates


additional commands

30
Solution Explorer

Toolbox
Solution Explorer

Properties

31

Solution Explorer

32

Solution Explorer

§ The Solution Explorer


Ÿ Lists all files in the solution
Ÿ Displays the contents or a new project or open file
Ÿ The start up project is the project that runs when the program is
executed
It appears in bold in the Solution Explorer
Ÿ The plus and minus images expand and collapse the tree
Can also double click on the file name to expand/collapse
Ÿ Solution Explorer toolbar
The Refresh icon reloads files in the solution
The Display icon shows all files, even the hidden ones
Icons change based on selected file
33
Solution Explorer

Refresh Display all files Properties window

Startup project

Collapse tree

Expand tree

34

Properties window

§ The Properties window


Ÿ Manipulate the properties of a form or control
Ÿ Each control has its own set of properties
Properties can include size, color, text, or position
Ÿ Right column is the property
Ÿ Left column is the property value
Ÿ Icons
The Alphabetic icon arranges the properties alphabetically
The Categorized icon arranges the properties by category
The Event icon allows reactions to user actions
Ÿ Users alter controls visually without writing code
Ÿ The component selection dropdown list shows what control is35
being altered and what other controls can be altered Slide 35 ©

Properties Window
Component selection
Characterized icon
Event icon

Alphabet icon

Scroll bar

Current value
Property

Description

36
Using Help

§ Help menu
Ÿ Index
Displays an alphabetic index that users can browse through
Ÿ Search
Allows users to search for a particular help topic
Filters can be use to narrow the search
§ Dynamic help
Ÿ Provide a help topic based on the mouse location
Ÿ Displays relevant topics in the dynamic help window
Ÿ Lists help entries, samples, and “getting started” topics
§ Context-Sensitive help
Ÿ Automatically brings up relevant help topics Slide 37
37
©

Using Help

Dynamic
Help window

38
Fig. 2.13 Dynamic Help window. Slide 38 ©

Naming Rules

§ Always use standard names for objects


§ No spaces or punctuation marks
§ 3 letter lowercase prefix identifies control type
Button-btn
Label-lbl
Form-frm
§ If multiple words capitalize 1st letter of each word

39
Recommended Naming Conventions for C#
Objects

Object Class Prefix Example


Form frm frmDataEntry
Button btn btnExit
TextBox txt txtPaymentAmount
Label lbl lblTotal
Radio Button rad radBold
CheckBox chk chkPrintSummary
Horizontal ScrollBar hsb hsbRate
Vertical ScrollBar vsb vsbTemperature
PictureBox pic picLandscape
ComboBox cbo cboBookList
ListBox lst lstIndegredients
40

Ví Dụ Đặt Tên

lblMessage

btnPush
btnExit

41

Sinh Viên Hãy Đặt Tên Sau

Name ? Name ?

Name ?
Name ?

Name ?

42
Simple Program: Displaying Text and
an Image

§ The program
Ÿ Form to hold other controls
Ÿ Label to display text
Ÿ PictureBox to display a picture
Ÿ No code needed to create this program
§ Create the new program
Ÿ Create a new project
Make the project a windows application
Name it: ASimpleProject and sets its location
§ Set the form’s title bar
Ÿ The Text property determines the text in the title bar
43
Ÿ Set the value to: A Simple Program Slide 43 ©

Ví dụ 1 Simple Program: Displaying


Text and an Image

44

Simple Program: Displaying Text and


an Image

Project type

Project name

Click to change
project location
Project location

45
Simple Program: Displaying Text and an
Image
Select project location

Click to set project location

46

Simple Program: Displaying Text and


an Image

Name and type of object

Selected property

Property value
Property description

47

Simple Program: Displaying Text and an


Image

Title bar

grid
Disabled sizing handle

Mouse pointer over


a sizing handle

Enabled sizing handle

48
Simple Program: Displaying Text and an
Image

Current color

Custom palette

Down arrow

49

Simple Program: Displaying Text and


an Image

Label
control

New background color

50

Simple Program: Displaying Text and


an Image

Label centered with


updated Text property

51
Simple Program: Displaying Text and
an Image

Updated Label
New PictureBox

52

Simple Program: Displaying Text and


an Image

Newly inserted image


(after resizing the
picture box)

53

Simple Program: Displaying Text and


an Image
Start button Run mode Design form

End button

Design form
(grid)

Running
application

54
Ví Dụ 2

Có cần đặt lại


tên ???? Có cần đặt lại
tên ????

lblKQua

btnVN

btnClose

btnSpan
btnEng
55

Code Cho Nút English

private void btnEngLish_Click(object sender, EventArgs e)


{
lblKQ.Text = "Hello"; 2

56

You might also like