Bachelor of Information Technology: Windows Programming
Bachelor of Information Technology: Windows Programming
Technology
WINDOWS PROGRAMMING
Introduction to Programming and
Visual C# 2008
(Week 1)
PowerPoint Slides
by Tengku Hasliza
Learning Objective(s)
1. Explain the process of visual program design and
development
2. Explain the term object-oriented programming
3. Explain the concepts of classes, objects, properties,
methods, and events
4. List and describe the three steps for writing a C# program
5. Describe the various files that make up a C# project
6. Identify the elements in the Visual Studio environment
7. Define design time, run time, and debug time
8. Write, run, save, print, and modify your first C# program
9. Identify syntax errors, run-time errors, and logic errors
Learning Outcome(s)
1. Describe the process of visual program design and
development
2. Explain the term object-oriented programming
3. Explain the concepts of classes, objects, properties,
methods, and events
4. Identify the three steps for writing a C# program
5. Describe the various files that make up a C# project
6. Identify the elements in the Visual Studio environment
7. Define design time, run time, and debug time
8. Write, run, save, print, and modify your first C# program
9. Identify syntax errors, run-time errors, and logic errors
Labels
Text boxes
Buttons
Radio buttons
Picture box
Check box
Menu Bar
Drop-down list
List box
Group box
Bradley (2009, Figure)
Programming Languages
Procedural and Object Oriented
Procedural Basic, C, Cobol, Fortran, PL/1, Pascal
Program specifies exact sequence of operations
Object Oriented Programming (OOP) C#, Java,
Visual Basic
Properties (adjectives)
Methods (verbs)
Forms, Controls
OOP Terminology
Object.Property
SalesForm.Text
Object.Method
BillingForm.Show
exitButton.Show
Programming Languages
C# Versions
10
Writing C# Programs
The Three-Step Process (Planning)
Planning
Design the user interface
Sketch screens
Show forms and all controls
Name forms and objects on form
Consult with user
11
Writing C# Programs
The Three-Step Process (Programming)
Define user interface
Create forms and controls
Set the properties
Name each object and define its attributes
Write the code
Define the actions of the program
12
C# Application Files
Solution file
A C# application is called a solution and can consist
of one or more projects
.sln extension
Project file
Describes project and lists files included
.csproj extension
Form files
.cs, .Designer.cs, .resx extensions
The Visual Studio environment creates several more files
13
Form designer
Editor for entering and modifying C# code
Compiler
Debugger
Object Browser
Help
14
15
Select Visual C#
Windows
16
Toolbo
x
Solution
Explorer
Properti
es
window
Main
Document
window
17
The Toolbars
Toolbar buttons are shortcuts
Each buttons command is also a menu selection
Select View/Toolbars to display or hide a toolbar
Three commonly used toolbars
Standard
Layout
Text Editor
18
Document Window
Use tabs to switch between open documents
Items in Document window
Form Designer
Code Editor
Project Designer
Database Designer
Object Browser
19
20
21
Toolbox
Holds tools to place controls on
form
Tools vary depending on edition
of C#
22
Help
Help with specific tasks
Filte
r
Help
Index
Selected Topic
Help
Contents
Help
Favorites
Help
Search
Index Results
23
24
25
26
Optional
Tools/Options
Options dialog box
Startup under Environment
At startup list
27
28
29
30
Controls
Select, Delete, Move or Resize
Select a control
Click on it
31
32
33
34
35
36
HelloForm.cs
Name of
the forms
file
File name
Name of
the form
class
37
Write Code
C# Events
While a project is running the user can perform
actions, each of which causes an event to occur
C# will execute a method when code has been written
for an event
C# ignores events for which no methods are written
38
C# Event Handlers
Write C# code in methods
Each begins with the words private void
Code in method is enclosed in braces { }
C# names the event-handling method as the object name,
an underscore (_) and the name of the event
displayButton_Click
39
C# Code Statements
Comment statements
Sometimes called remarks
Ending a statement
Code statements are terminated by a semicolon (;)
Assignment statements
Executing a Method
Methods always have parentheses
Use this keyword to execute method of the current
form
40
end with */
41
Ending a Statement
Most C# statements end with a semicolon (;)
A statement can appear on multiple lines
The semicolon determines the end of the statement
Comments and a few other C# statements do not end with
a semicolon
42
messageLabel.Text = "Hello
World";
I-Station Solutions Sdn Bhd
43
44
45
Editor
tab
Commen
t
statemen
Assignme
t
nt
statement
Execute the
Close
method to
end the
program
46
47
Hello World
message appears
in the label
48
49
50
Click to
expand Font
list
Properties button
Settings
box
51
52
System.Windows.Forms
Allows program to refer to all Windows controls
Namespace Statement
.NET Framework requires every program component
to have a namespace
Class Statement
A new class can inherit from another class
53
54
Project Debugging
Program errors are bugs
Editor highlights syntax and run-time errors
Programmer must locate logic errors
C# allows edit-and-continue
Fix error and press F5 or Debug/Continue
Clean Compile
No errors during the compile process
55
Select the
event
56
57
58
59
60
61
62
References:
Julia Case Bradley, Anita Millspaugh. 2010, Programming
in Visual C# 2008, Mc Graw Hill.
Last
updated: 3/7/15
Last
Updated:
63
Key Terms:
Term
Definition
Forms
Controls
Syntax errors
Run-time errors or
exceptions
Logic errors
64