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 CÀI ĐẶT MSDN Help.
Trang 1Chapter 1
Visual Studio 2005
2
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ờ)
Trang 2CÀ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
CÀI ĐẶT Visual Studio.NET 2005 Lựa chọn và yêu cầu phần khoảng trống ổ cứng
Trang 3CÀ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
CÀI ĐẶT MSDN (Help)
Trang 4CÀI ĐẶT MSDN (Help)
11
CÀI ĐẶT MSDN (Help)
•Nên chọn full
CÀI ĐẶT MSDN (Help)
Trang 5CÀI ĐẶT MSDN (Help)
14
CÀI ĐẶT MSDN (Help)
Introduction
Ÿ Framework.
Ÿ Microsoft’s Integrated Development Environment (IDE)
Trang 6The 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
17
The Net Framework
Understanding the NET Framework Architecture
Understanding the Common Language
Runtime Common Language Runtime Architecture
Trang 7Programming 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#
Visual Basic
Code VisualBasicCompiler
COBOL
Code CompilerCOBOL
Native Code
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)
Trang 8Dot 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
Steps for Writing C#
§ Design/Define the User Interface
Trang 9Visual Studio NET Integrated Development
Environment (IDE) Overview
26
Visual Studio NET Integrated Development
Environment (IDE) Overview
Visual C#
projects folder
project name
project location
Visual C# Windows
Application (selected)
IDE Main Window
§ Toolbars
§ Document Window
§ Form Designer
§ Solution Explorer
§ Properties Window
§ Toolbox
Trang 10Visual Studio NET Integrated Development
Environment (IDE) Overview
tabs
menu bar
Explorer
Properties
window
Form
(windows
application)
29
Toolbox
toolbox group
controls
scroll arrow
§ Holds the tools
you place on a
form
Menu Bar and Toolbar
toolbar icon (indicates a command to open a file)
Trang 11Solution Explorer
Properties
Toolbox Solution Explorer
32
Solution Explorer
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 Explorertoolbar
The Refresh icon reloads files in the solution
The Display icon shows all files, even the hidden ones
Icons change based on selected file
Trang 12Solution 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
Properties Window
Alphabet icon
Characterized icon
Event icon Component selection
Trang 13©
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 Help window
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
Trang 14Recommended Naming Conventions for C#
Objects
Object Class Prefix Example
41
Ví Dụ Đặt Tên
lblMessage
btnPush btnExit
Sinh Viên Hãy Đặt Tên Sau
Name ? Name ?
Trang 15©
Slide 43
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
ŸSet the value to: A Simple Program
44
Ví dụ 1 Simple Program: Displaying
Text and an Image
Simple Program: Displaying Text and
an Image
Project name
Project location
Click to change project location Project type
Trang 16Simple 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
Simple Program: Displaying Text and an
Image
Title bar
Trang 17Simple 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
Simple Program: Displaying Text and
an Image
Label centered with
updated Text property
Trang 18Simple 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)
Simple Program: Displaying Text and
an Image
Start button Run mode Design form
Trang 19Ví 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";
}