C# Note

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

C# Graphical User Interface

The direct manipulation of graphical icons, such as buttons, scroll bars, windows, tabs, menus, cursors,
and the mouse pointing device, is becoming the standard for user-centered design in software
application programming. Graphical user interfaces (GUIs) allow users to operate computers and other
electronic devices intuitively. Many current graphical user interfaces have a touchscreen and voice-
command feature.

C# has all the features of any powerful, modern language. In C#, the most rapid and convenient way to
create your user interface is to do so visually, using the Windows Forms Designer and Toolbox. Windows
Forms controls are reusable components that encapsulate user interface functionality and are used in
client side Windows based applications.

Elements in Graphical User Interface

Graphical User Interface makes use of visual elements mostly. These elements define the
appearance of the GUI. Some of these are described in detail as follows:

Window

This is the element that displays the information on the screen. It is very easy to manipulate a
window. It can be opened or closed with the click of an icon. Moreover, it can be moved to any
area by dragging it around. In a multitasking environment, multiple windows can be open at the
same time, all of them performing different tasks.

There are multiple types of windows in a graphical user interface, such as container window,
browser window, text terminal window, child window, message window etc.

Menu

A menu contains a list of choices and it allows users to select one from them. A menu bar is
displayed horizontally across the screen such as pull-down menu. When any option is clicked in
this menu, then the pull-down menu appears.

Another type of menu is the context menu that appears only when the user performs a specific
action. An example of this is pressing the right mouse button. When this is done, a menu will
appear under the cursor.

Menu Control What It Does


ContextMenu Menus that are invoked by right-clicking a
control.
Menu Control What It Does
MainMenu Resides at the top of a form, below its title
bar. It is the root menu of an entire menu
hierarchy.
MenuItem Sub-menus of a MainMenu and other
MenuItems. They form the branches and
nodes of the menu hierarchy. MenuItems are
used to invoke some capability of a program.

Icons

Files, programs, web pages etc. can be represented using a small picture in a graphical user
interface. This picture is known as an icon. Using an icon is a fast way to open documents, run
programs etc. because clicking on them yields instant access.

Controls
Information in an application can be directly read or influenced using the graphical control
elements. These are also known as widgets. Normally, widgets are used to display lists of similar
items, navigate the system using links, tabs etc. and manipulating data using check boxes, radio
buttons etc.

A control is a component on a form used to display information or accept user input. The Control class
provides the base functionality for all controls that are displayed on a Form.

You can use this.Controls collection to enumerate through all the controls

Control Prefix Comments


BackgroundWorker Allows the user to to execute an operation on
a separate (dedicated) thread.
Button btn Allows the user to run a separate subroutine.
CheckBox chb Allows the user to either select or deselect an
option.
CheckedListBox chlb Allows the user to select multiple items from
a list of items.
ComboBox cbo Allows the user to either select an item from a
drop-down box or enter a different item.
DataGridView dgr Allows the user to display (and edit) a table of
information.
DateTimePicker dtp Allows the user to select a specific date and/or
time.
DHTML Editing Control Allows the user to display a web page (not
supported).
FolderBrowseDialog fol Allows the user to browse, create and select
folders (not files).
GroupBox grp Allows you to group other controls together.
ImageList img Allows you to have a repository of images in
your assembly.
Label lbl Allows you to display text to the user.
LinkLabel llb Allows you to include hyperlinks in your text.
ListBox lsb Allows the user to select an item from a list of
items.
ListView lsv Allows the user to select a single (or multiple)
items from a list with multiple columns.
MenuStrip msp Allows the user to group commands by a
common theme.
NumericUpDown nud Allows the user to display numeric values.
Panel pnl Allows the user an area for grouping controls
and scrolling.
PictureBox pic (Image) Allows you to display a graphic or
picture.
ProgressBar Allows the user to indicate progress using a
graphical bar.
RadioButton rad (OptionButton) Allows the user to select from
a list of possible distinct options.
RefEdit
RichTextBox rch Allows the user to display text with
formatting.
SplitContainer spl Allows you to split an area into two resizeable
panels.
StatusStrip Allows you to add a status bar to your
window.
TabControl tab Allows you to display multiple tabs of the
same controls.
TableLayoutPanel
TextBox txt (EditBox) Allows you to display text and to
allow the user to enter information.
ToolTip tip Allows you to display text when you hover
over other controls.
ToolStrip tls Represents a panel in a StatusStrip control.
ToolStripButton tlsb Represents a selectable item for a ToolStrip
control.
TreeView tvw Allows you to display a hierarchy of nodes
with parents and child.
VScrollBar vsb Allows the user to drag a button in order to
select a value.
WebBrowser wbr Allows the user to include a web browser on a
form.
Asp. Net-Web forms and web Controls
ASP.NET
It is a web framework designed and developed by Microsoft. It is used to develop websites, web
applications and web services. It provides fantastic integration of HTML, CSS and JavaScript. It was first
released in January 2002. It is built on the Common Language Runtime (CLR) and allows programmers to
write code using any supported .NET language.

ASP.NET Web Forms


Web Forms are web pages built on the ASP.NET Technology. It executes on the server and
generates output to the browser. It is compatible to any browser to any language supported by
.NET common language runtime. It is flexible and allows us to create and add custom controls.

We can use Visual Studio to create ASP.NET Web Forms. It is an IDE (Integrated Development
Environment) that allows us to drag and drop server controls to the web forms. It also allows us
to set properties, events and methods for the controls. To write business logic, we can choose any
.NET language like: Visual Basic or Visual C#.

Web Forms are made up of two components: the visual portion (the ASPX file), and the code
behind the form, which resides in a separate class file.

Fig: This diagram shows the components of the ASP.NET

The main purpose of Web Forms is to overcome the limitations of ASP and separate view from the
application logic.
ASP.NET provides various controls like: server controls and HTML controls for the Web Forms. We have
tables all these controls below.

Server Controls

The following table contains the server-side controls for the Web Forms.

Control Name Applicable Events Description


Label None It is used to display text on the
HTML page.
TextBox TextChanged It is used to create a text input
in the form.
Button Click, Command It is used to create a button.
LinkButton Click, Command It is used to create a button that
looks similar to the hyperlink.
ImageButton Click It is used to create an
imagesButton. Here, an image
works as a Button.
Hyperlink None It is used to create a hyperlink
control that responds to a click
event.
DropDownList SelectedIndexChanged It is used to create a dropdown
list control.
ListBox SelectedIndexCnhaged It is used to create a ListBox
control like the HTML control.
DataGrid CancelCommand, EditCommand, It used to create a frid that is
DeleteCommand, ItemCommand, used to show data. We can also
SelectedIndexChanged, perform paging, sorting, and
PageIndexChanged, SortCommand, formatting very easily with this
UpdateCommand, ItemCreated, control.
ItemDataBound
DataList CancelCommand, EditCommand, It is used to create datalist that
DeleteCommand, ItemCommand, is non-tabular and used to show
SelectedIndexChanged, data.
UpdateCommand, ItemCreated,
ItemDataBound
Repeater ItemCommand, ItemCreated, It allows us to create a non-
ItemDataBound tabular type of format for data.
You can bind the data to
template items, which are like
bits of HTML put together in a
specific repeating format.
CheckBox CheckChanged It is used to create checkbox.
CheckBoxList SelectedIndexChanged It is used to create a group of
check boxes that all work
together.
RadioButton CheckChanged It is used to create radio button.
RadioButtonList SelectedIndexChanged It is used to create a group of
radio button controls that all
work together.
Image None It is used to show image within
the page.
Panel None It is used to create a panel that
works as a container.
PlaceHolder None It is used to set placeholder for
the control.
Calendar SelectionChanged, It is used to create a calendar.
VisibleMonthChanged, DayRender We can set the default date,
move forward and backward
etc.
AdRotator AdCreated It allows us to specify a list of
ads to display. Each time the
user re-displays the page.
Table None It is used to create table.
XML None It is used to display XML
documents within the HTML.
Literal None It is like a label in that it
displays a literal, but allows us
to create new literals at runtime
and place them into this control.

HTML Controls

These controls render by the browser. We can also make HTML controls as server control. we
will discuss about this in further our tutorial.

Controls Description
Name
Button It is used to create HTML button.
Reset Resets all other HTML form elements on a form to a default value
Button
Submit Automatically POSTs the form data to the specified page listed in the Action
Button attribute in the FORM tag
Text Field Gives the user an input area on an HTML form
Text Area Used for multi-line input on an HTML form
File Field Places a text field and a Browse button on a form and allows the user to select a
file name from their local machine when the Browse button is clicked
Password An input area on an HTML form, although any characters typed into this field
Field are displayed as asterisks
CheckBox Gives the user a check box that they can select or clear
Radio Used two or more to a form, and allows the user to choose one of the controls
Button
Table Allows you to present information in a tabular format
Image Displays an image on an HTML form
ListBox Displays a list of items to the user. You can set the size from two or more to
specify how many items you wish show. If there are more items than will fit
within this limit, a scroll bar is automatically added to this control.
Dropdown Displays a list of items to the user, but only one item at a time will appear. The
user can click a down arrow from the side of this control and a list of items will
be displayed.
Horizontal Displays a horizontal line across the HTML page
Rule

ASP.NET Web Forms Features


ASP.NET is full of features and provides an awesome platform to create and develop web
application. Here, we are discussing these features of Web Forms.

 Server Controls
 Master Pages
 Working with data
 Membership
 Client Script and Client Frameworks
 Routing
 State Management
 Security
 Performance
 Error Handling

Server Controls

Web Forms provides rich set of server controls. These controls are objects that run when the page
is requested and render markup to the browser. Some Web server controls are similar to familiar
HTML elements, such as buttons and text boxes. It also provides controls that we can use to
connect to data sources and display data.

Master Pages

It allowsus to create a consistent layout for the pages in our application. This page defines the look
and feel and standard behavior that we want for all of the pages in our application. When users
request the content pages, they merge with the master page to produce output that combines the
layout of the master page with the content from the content page.
Working with Data

In an ASP.NET Web Forms application, we use data-bound controls to automate the presentation
or input of data in web page UI elements such as tables and text boxes and drop-down lists.

Membership

Project's Account folder contains the files that implement the various parts of membership:
registering, logging in, changing a password, and authorizing access. Additionally, ASP.NET
Web Forms supports OAuth and OpenID. These authentication enhancements allow users to log
into your site using existing credentials, from such accounts as Facebook, Twitter and Google.

Client Script and Client Frameworks

We can enhance the server-based features of ASP.NET by including client-script functionality in


ASP.NET Web Form pages. We can use client script to provide a richer, more responsive user
interface to the users. We can also use client script to make asynchronous calls to the Web server
while a page is running in the browser.

Routing

We can configure URL routing of our application. A request URL is simply the URL a user
enters into their browser to find a page on our web site. We use routing to define URLs that are
semantically meaningful to users and that can help with search-engine optimization (SEO).

State Management

ASP.NET Web Forms includes several options that help you preserve data on both a per-page
basis and an application-wide basis.

Security

Developing a secure application is most important aspect of software development process.


ASP.NET Web Forms allow us to add extensibility points and configuration options that enable
us to customize various security behaviors in the application.

Performance

Web Forms provides good performance and allows us to modify performance related to page and
server control processing, state management, data access, application configuration and loading,
and efficient coding practices.
Debugging and Error Handling

We can diagnose problems that occur in our Web Forms application. Debugging and error
handling are well supported within ASP.NET Web Forms so that our applications compile and
run effectively.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy