0% found this document useful (0 votes)
51 views25 pages

C# Chapter 4

The document discusses adding multiple forms to a Visual C# project and connecting forms to databases. It covers creating new forms, displaying forms, hiding and closing forms, and responding to form events. It also discusses using ADO.NET to connect to databases and perform CRUD operations on data with controls like DataGridView.

Uploaded by

Salman Sead
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views25 pages

C# Chapter 4

The document discusses adding multiple forms to a Visual C# project and connecting forms to databases. It covers creating new forms, displaying forms, hiding and closing forms, and responding to form events. It also discusses using ADO.NET to connect to databases and perform CRUD operations on data with controls like DataGridView.

Uploaded by

Salman Sead
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 25

Programming with Visual C#

Chapter 4

Multiform Projects and Database Applications


Using Multiple Forms
 All the projects that you have created up to now
have operated from a single form.
 The first form a project displays is called the
startup form .
 You can add more forms to the project and display
them as needed. A project can have as many forms
as you wish.
Creating New Forms
 To add a new form to a project, select Add
Windows Form from the Project menu.
 You can select from many installed templates.
Windows Form Templates
An About Box
 One popular type of form in a project is an About
box , such as the one you find in most Windows
programs under Help / About .
 Usually an About box gives the name and version
of the program as well as information about the
programmer or company.
An About Box
Displaying an About Form
MDI Parent Forms
Dashboard Form
 Dashboard is a type of graphical user interface
which often provides at-a-glance views of
objective and business processes of the
application.
Dashboard for School Management
System
Hiding or Closing a Form
 You already know how to close the current form:
this.Close();
 You also can use the Close method to close any
other form:

 You can also hide a form using this method


Responding to Form Events
 The two primary events for which you may need to write
code are :
1. Form .Load
2. Form .Activated.
 The first time a form is shown in an application, both the
Load and Activated events occur.
 The Load event occurs when the form is loaded into
memory
 The Activated event occurs after the Load event, just as
control is passed to the form.
Connecting C# with Databases
 You can use C# to write applications that interact
with databases.
 Databases are composed of tables of related
information.
 Each table is organized into rows representing
records and columns containing fields of data.
ADO.NET and C#
 ADO stands for Microsoft ActiveX Data Objects.
ADO.NET is one of Microsoft’s Data Access
Technologies, using which we can communicate with
different data sources.
 It is a part of the .NET Framework, which connects
the .NET Application (Console, WCF, WPF,
Windows, MVC, Web Form, etc.) and different data
sources.
 The Data Sources can be SQL Server, Oracle,
MySQL, XML, etc
ADO.NET Architecture
ADO.NET Components
 There are a number of key classes that are available in
ADO.NET that allows us to work with data in a database.
 Briefly they are:
 SqlConnection - specify the connection to the database.

 SqlCommand – send SQL statements to the database.

 SqlDataReader – obtain results from a SELECT SQL

statement.
 DataSet – memory representation of the database.

 SqlDataAdapter – exchanges data between a DataSet

and a Database.
ADO.NET Components
DataGridView
 The DataGridView control provides a powerful
and flexible way to display data in a tabular
format.
 You can use the DataGridView control to show
read-only views of a small amount of data, or you
can scale it to show editable views of very large
sets of data.
DataGrid View
Creating a Database Application (GRUD
Operation)
 CRUD stands for create, read, update, and delete.
These are the four basic functions of persistent
storage.
 It can also describe user-interface conventions that
allow viewing, searching, and modifying
information through computer-based forms and
reports.
Simple GRUD Application with
DataGrid View
Simple CRUD Application with
Search Button
More Complex CRUD Application
Thank you

You might also like