Tải bản đầy đủ (.pdf) (19 trang)

Chapter 1 Introduction to the Visual Studio 2005

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (365.15 KB, 19 trang )

1
Chapter 1
üIntroduction to the
Visual Studio 2005
2
INTRODUCTION
§ Included in Visual Studio.NET
Ÿ Visual Basic (VB.Net, VB 7.0)
Ÿ C++
Ÿ C# (đọc làCSharp)
Ÿ J# (J Sharp)
Ÿ .NET Framework
3
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ờ)
4
CÀI ĐẶT Visual Studio.NET 2005
Nhấn
Next
5
CÀI ĐẶT Visual Studio.NET 2005
Nhấn Next
§ Thường các Key đã cósẵn
6
CÀI ĐẶT Visual Studio.NET 2005
Chúý
Lựa chọn vàyêu cầu phần khoảng trống ổ cứng
7
CÀI ĐẶT Visual Studio.NET 2005
•Cài đặt từng phần tốn khá
nhiều thời gian


8
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
9
CÀI ĐẶT MSDN (Help)
10
CÀI ĐẶT MSDN (Help)
11
CÀI ĐẶT MSDN (Help)
•Nên chọn full
12
CÀI ĐẶT MSDN (Help)
13
CÀI ĐẶT MSDN (Help)
14
CÀI ĐẶT MSDN (Help)
15
Introduction
§Visual Studio .NET
Ÿ Framework.
Ÿ Microsoft’s Integrated Development Environment
(IDE)
16
The .NET Framework
§ The Common Language Runtime (CLR) is another
central part of the .NET Frameworkitexecutes .NET
programs
§ The .NET Framework Class Library (FCL) can be
used by any .NET language.

17
The .Net Framework
Understanding the .NET Framework Architecture
18
Understanding theCommonLanguage
Runtime
Common Language Runtime Architecture
19
Programming Languages
§ Procedural
Ÿ Program specifies exact sequence
§ Event Driven
§ Object Oriented Programming (C#.NET)
Ÿ User controls sequence
Click event
Double Click event
Change event
20
Quátrình biên dịch vàchạy một chương trình trên nền
.NET
C#
Code
C#
Compiler
Visual Basic
Code
VisualBasic
Compiler
COBOL
Code

COBOL
Compiler
IL
JIT
Compiler
Native
Code
21
Object Model
§ Object ==> Like a Noun in English
Ÿ Form and Controls on forms (Button, Text boxes…)
§ Property ==> Like Adjective,theydescribe 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)
22
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
}
23
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
24
Steps for Writing C#
§ Design/Define the User Interface
§ Plan/Set the Properties
§ Plan/Write the Code
§ Test and Debug
25
Visual Studio .NET Integrated Development
Environment (IDE) Overview
26
VisualStudio .NET Integrated Development
Environment (IDE) Overview
Visual C#
projects folder
project name
project location
Visual C# Windows
Application (selected)
27
IDE Main Window

§ Toolbars
§ Document Window
§ Form Designer
§ Solution Explorer
§ Properties Window
§ Toolbox
28
VisualStudio .NET Integrated Development
Environment (IDE) Overview
tabs
menu title bat
menu bar
active tab
Solution
Explorer
Properties
window
Form
(windows
application)
29
Toolbox
toolbox group
controls
scroll arrow
§ Holds the tools
you place on a
form
30
Menu Bar and Toolbar

toolbar icon (indicates a command to open a file)
down arrow indicates
additional commands
toolbar
31
SolutionExplorer
Properties
Toolbox
Solution Explorer
32
Solution Explorer
33
Solution Explorer
§ The SolutionExplorer
Ÿ 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 SolutionExplorer
Ÿ The plus and minus images expand and collapse the tree
Can also double click on the file name to expand/collapse
Ÿ SolutionExplorer 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
34
Solution Explorer
Refresh Display all files
Startup project
Collapse tree

Expand tree
Properties window
35
©
Slide 35
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 is
being altered and what other controls can be altered
36
Properties Window
Alphabet icon
Characterized icon
Event icon
Component selection
Scroll bar
Current value
Property
Description
37

©
Slide 37
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
38
©
Slide 38
Using Help
Fig. 2.13 Dynamic Help window.
Dynamic
Helpwindow
39
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
40
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
41
VíDụ Đặt Tên
lblMessage
btnPush
btnExit
42
Sinh Viên Hãy Đặt Tên Sau
Name ?
Name ?
Name ?
Name ?
Name ?
43
©

Slide 43
Simple Program: Displaying Text and
an Image
§ The program
Ÿ Form to hold other controls
Ÿ Label to display text
Ÿ PictureBoxto 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: ASimpleProjectand sets its location
§ Set the form’s title bar
Ÿ The Text property determines the text in the title bar
Ÿ Set the value to: A Simple Program
44
V
í
d

1
Simple Program: Displaying
Text and an Image
45
Simple Program: Displaying Text and
an Image
Project name
Project location
Click to change
project location

Project type
46
Simple
Program: Displaying Text and an
Image
Select project location
Click to set project location
47
Simple Program: Displaying Text and
an Image
Name and type of object
Property value
Selected property
Property description
48
Simple
Program: Displaying Text and an
Image
grid
Mouse pointer over
a sizing handle
Enabled sizing handle
Disabled sizing handle
Title bar
49
Simple
Program: Displaying Text and an
Image
Down arrow
Current color

Custom palette
50
Simple Program: Displaying Text and
an Image
Label
control
New background color
51
Simple Program: Displaying Text and
an Image
Label centered with
updated Text property
52
Simple Program: Displaying Text and
an Image
Updated Label
New PictureBox
53
Simple Program: Displaying Text and
an Image
Newly inserted image
(after resizing the
picture box)
54
Simple Program: Displaying Text and
an Image
Start button
End button
Run mode Design form
Design form

(grid)
Running
application
55
VíDụ2
lblKQua
btnVN
btnClose
btnSpan
btnEng
Cócần đặt lại
tên ????
Cócần đặt lại
tên ????
56
Code Cho Nút English
1
2
private void btnEngLish_Click(object sender, EventArgs e)
{
lblKQ.Text = "Hello";
}

×