CS6004 Application Development - Lecture5
CS6004 Application Development - Lecture5
Application
Development
Lecture 5
Chamila Karunatilake
[email protected]
1
Outline
2
Windows Forms Applications
3
Windows Forms Applications
4
.NET Desktop Development
First, you'll create a C# application project. The project type comes with all
the template files you'll need, before you've even added anything.
• Open Visual Studio.
• On the start window, select Create a new project.
• It is possible to select one of the three types of projects from below.
– Windows Forms App
– Windows Forms App (.NET Framework)
– WPF Application
5
Static Modifier
6
Windows Forms App (.NET Framework)
• Visual Studio gives developers the option of creating projects based on
.NET Framework or .NET Core. Both have been superseded with the
release of .NET 5.
• Developers still have the option to create projects with the .NET
Framework.
• .NET Framework is older than .NET Core, and runs on Windows only.
• When .NET Core 3.0 was released, Microsoft began recommending that
new applications, regardless of what type, be developed with .NET Core.
Microsoft also announced that there would be no further major update
to the .NET Framework.
7
Windows Forms App
• With .NET 5, Windows Forms Application(.NET Core) became the
default. (Windows Forms App is .NET Core 3.0 or newer.)
• .NET Core was created to be cross-platform, and originally did not
support Windows desktop apps.
• Best practice is to choose "Windows Forms App" for new development.
8
WPF Application
• WPF stands for Windows Presentation Foundation.
• WPF is a UI framework used for developing Windows or desktop client
applications.
• It is the latest approach to the GUI framework being used with the .NET
framework.
• It has all the functionality that is being required to develop, run,
execute, manage, and handle Windows client applications.
• It generally provides holistic means for combining or integrating UI, 2D
and 3D graphics, digital media, and documents.
• It is the current platform for developing windows applications.
9
10
Important parts of Designer Window
11
Important parts of Designer Window
1. Solution Explorer
– All of your project files, code, forms, resources, will appear in this
pane.
2. Properties
– This pane shows property settings you can configure based on the
item selected.
– For example, if you select an item from Solution Explorer, you'll see
property settings related to the file.
– If you select an object in the Designer, you'll see settings for the
control or form.
12
Important parts of Designer Window
3. Form Designer
– This is the designer for the form. It's interactive and you can drag-
and-drop objects from the Toolbox.
– By selecting and moving items in the designer, you can visually
compose the user interface (UI) for your app.
4. Toolbox
– The toolbox contains all of the controls you can add to a form.
– To add a control to the current form, double-click a control or drag-
and-drop the control.
13
Important Files of the Project
• program.cs is the main of the application. This
will be executed first when the application
runs.
• Form1.cs is the code-behind file of the
windows form. It is the class file of the
windows form where the necessary methods,
functions also event driven methods and codes
are written.
• Form1.designer.cs is the designer file where
form elements are initialized. If any element is
dragged and dropped in the form window, then
that element will be automatically initialized in
14
this class.
Form1.cs [Design]
15
Form1.cs
16
Form1.Designer.cs
17
Program.cs
18
Project File
• The project file is an XML
document that contains
all the information and
instructions that
MSBuild needs in order
to build your project, like
the content to include,
the platform
requirements, versioning
information, web server
or database server
settings, and the tasks
that must be performed.
19
Toolbox
20
Controls
21
Controls
22
Controls
23
Controls
24
Controls
25
Controls and Properties
26
Control Properties
27
Control Events
29
Control Events and Event Handlers
31