Chapter 2

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 116

Chapter 2 Introduction to.

o The .NET Platform and Its Architecture


- Base Class Library
- Common Language Runtime
o Uses of .NET Platform in Application
Development
o Introduction to Microsoft Visual Studio 2010
- SDI and MDI Forms
- Controls
What is .NET Framework?

o.NET Framework (pronounced dot net) is a 


software framework developed by Microsoft that
runs primarily on Microsoft Windows.
oThe .NET framework is Internet-oriented.
o.NET Framework is a complete environment that

allows developers to develop, run, and deploy the


following applications:
 Console applications
 Windows Forms applications
 Windows Presentation Foundation (WPF)

applications
 Web applications (ASP.NET applications)
 Web services
 Windows services
 Workflow-enabled applications using Windows

Workflow Foundation (WF)


o .NET Framework also enables a developer to create
sharable components to be used in distributed computing
architecture .
o . NET Framework supports the object-oriented
programming model for multiple languages, such as
Visual Basic, Visual C#, and Visual C++.
o .NET Framework supports multiple programming
languages in a manner that allows language
interoperability.
o This implies that each language can use the code written
in some other language.
o The .NET Framework version 4 redistributable packages
are available in two profiles: Full Profile & Client Profile.
Installation Requirements
1.Software Requirements
• To install the .NET Framework 4, one of the following

operating systems must be installed on the target


computer:
• Windows 7 family.

• Windows Server 2008 R2 family.

• Windows Vista(a mental view of an imagined future event or situation ) family.


 Windows Server 2008 family.
 Windows XP Home or Microsoft Windows XP Professional,

both with Service Pack 3 or later.


 Windows 2003 family with Service Pack 2 or later.

2.Hardware Requirements
o The first level of the representation is the operating
system the .NET layer is located between the system and
applications.
o The second level is the Common Language
Runtime(CLR), which provides the part of the .NET
Framework doing the most work.
o The next level is the Base Class Library (BCL), which
provides all .NET objects that can be used both in your
code and by Visual Basic when creating applications.
o The last level is represented by applications that rely on
the previous layers.
o .NET Framework provides enormous advantages to
software developers in comparison to the advantages
provided by other platforms.
o Microsoft has united various modern as well as existing
technologies of software development in .NET
Framework.
o These technologies are used by developers to develop
highly efficient applications for modern as well as future
business needs.
o .NET Framework Class Library
o Common Language Runtime
o Dynamic Language Runtimes (DLR)
o Application Domains
o Runtime Host
o Common Type System
o Cross-Language Interoperability
o .NET Framework Security
o Side-by-Side Execution
o The .NET Framework is shipped with compilers of all .NET
programming languages to develop programs.
o There are separate compilers for the Visual Basic, C#, and
Visual C++ programming languages in .NET Framework
o Each .NET compiler produces an intermediate code after
compiling the source code.
o The intermediate code is common for all languages and is
understandable only to .NET environment.
o This intermediate code is known as MSIL
Intermediate Language:-
o is also known as MSIL (Microsoft Intermediate Language)

or CIL (Common Intermediate Language).


oAll .NET source code is compiled to Intermediate Language

(IL).
oIL is then converted to machine code at the point where the

software is installed, or at run-time by a Just-In-Time (JIT)


compiler.
o Provides an infrastructure that is common to all .NET
languages.
o CLR provides an environment to execute .NET applications
on target machines.
o CLR provides services to executing programs.
o Traditionally, different programming environments have
different runtimes.
o Examples of runtimes include the standard C library, the
Visual Basic runtime, and the Java Virtual Machine (JVM).
o The code which runs under the CLR is called as Managed
Code.
o Programmers need not to worry on managing the memory
if the programs are running under the CLR as it provides
memory management and thread management.
o Programmatically, when our program needs memory, CLR
allocates the memory for scope and de-allocates the
memory if the scope is completed.
o CLR is also a common runtime environment for all .NET
code irrespective of their programming language, as the
compilers of respective language in .NET Framework
convert every source code into a common language
known as MSIL or IL (Intermediate Language).
o CLR also provides various services to execute processes,
such as memory management service and security
services.
o CLR performs various tasks to manage the execution
process of .NET applications.
o The responsibilities of CLR are listed as follows:

• Automatic memory management


• Garbage Collection
• Code Access Security
• Code verification
• JIT compilation of .NET code
The CLR provides the following benefits:
oPerformance improvements.
oThe ability to easily use components developed in other

languages.
oExtensible types provided by a class library.

oLanguage features such as inheritance, interfaces, and

overloading for object-oriented programming.


oSupport for structured exception handling.

oSupport for custom attributes.

oGarbage collection.
o Managed code:- is the code that is executed directly by
the CLR instead of the operating system.
o The code compiler first compiles the managed code to
intermediate language (IL) code, also called as MSIL code.
o This code doesn't depend on machine configurations and
can be executed on different machines.
• In the managed code, since the execution of the code is
governed by CLR, the runtime provides different services,
such as garbage collection, type checking, exception
handling, and security support.
o These services help provide uniformity in platform and
language-independent behavior of managed code
applications.
The execution process for managed code.
A piece of managed code is executed as follows:
o Choosing a language compiler

o Compiling the code to MSIL

o Compiling MSIL to native code

o Executing the code.


o Unmanaged code:- is the code that is executed directly by
the operating system outside the CLR environment.
o It is directly compiled to native machine code which
depends on the machine configuration.
o In the unmanaged code, the allocation of memory, type
safety, and security is required to be taken care of by the
developer.
o If the unmanaged code is not properly handled, it may
result in memory leak (of a container or covering).
o Examples of unmanaged code are ActiveX components and
Win32 APIs that execute beyond the scope of native CLR
o What is the role of the JIT compiler in .NET Framework?
 The JIT compiler is an important element of CLR.
 which loads MSIL on target machines for execution.
 The MSIL is stored in .NET assemblies after the developer
has compiled the code written in any .NET-compliant
programming language, such as Visual Basic and C#.
 JIT compiler translates the MSIL code of an assembly and
uses the CPU architecture of the target machine to execute
a .NET application
o It also stores the resulting native code so that it is
accessible for subsequent calls.
o If a code executing on a target machine calls a non-native
method, the JIT compiler converts the MSIL of that method
into native code.
o JIT compiler also enforces type-safety in runtime
environment of .NET Framework.
o It checks for the values that are passed to parameters of
any method.
o This is also called as Base Class Library.
o It is common for all types of applications i.e. the way you
access the Library Classes and Methods in VB.NET will be
the same in C#
o It is common for all other languages in .NET. 
o The .NET Framework class library is huge, comprising
more than 2,500 classes.
o All this functionality is available to all the .NET languages.
The .NET Framework Class Library consists of four main parts:
1.Base class library (which includes networking, security,
diagnostics, I/O, other types of operating system services)
2. Data and XML classes
3.Windows UI(user interface)
4.Web services and Web UI
The following are different types of applications that can make use
of .NET class library. 
1.Windows Application.
2.Console Application
3.Web Application.
4.XML Web Services. 5.Windows Services.
Uses of .NET Platform in Application Development

Assignment
Introduction to Microsoft
Visual Studio 2010
o Create a Visual Basic 2010 Windows-based application
o Manage the windows in the Integrated Development
Environment (IDE)
o Set the properties of an object
o Add a control to a form
o Enter code in the Code Editor window
o Save a solution
o Start and end an application
o Close and open an existing solution
o Find and correct a syntax error
 Visual programming is the creation of a computer program
by utilizing pictorial elements. ex. VB.NET
 Visual programming language (VPL) is any programming
language that lets users create programs by manipulating
program elements graphically rather than by specifying
them textually.
 A VPL allows programming with visual expressions, spatial
arrangements of text and graphic symbols, used either as
elements of syntax or secondary notation.
o User friendly & interactive using integrated development
environment (“IDE“).
o Support rapid application development
o Allows rapid design and prototype of Windows
applications
o Provide an effective development communication tool
o Easy to develop graphical user interfaces
o Multiple vendor support
o Most visual basic .NET is an Event driven program that
communicates with the users through GUI.
o That means users employ the GUI objects to select options,
to enter data, and cause events to occur.
o Graphical User Interface - consists of graphical objects
such as icons that are used by the end user to interact with
the operating system.
o The most famous GUI program is the Microsoft Windows
desktop.
VB.NET
ois an event driven programming language that allows to
build application/program for windows operating system and
the web.
osince it is one of the modern programming language ,it is

more object oriented.


oIs based on visual basic programming language which

evolved form BASIC(Beginners All-purpose Symbolic


Instruction Code)
o Is available in a stand-alone edition i.e. visual basic .NET
standard Edition, a Professional Edition, an Enterprise
developer Edition , and an Enterprise Architect Edition,
o Also is package in several edition of Microsoft Visual Studio.NET,
which is comprehensive set of programming languages and tools
for building :
• Windows application,
• web application and other programs and service.
o Compile to a common machine language, called MSIL(Microsoft
intermediate language).
o MSIL code ,called managed code, runs in the common language
Runtime CLR which is part of the .NET Framework.
o Application:- program or suite of programs.
o is a program that tells a computer how to accept
instruction and data from users and how to produce
information in response to those instructions.
o Is a collection of one or more program that is designed to
complete a specific task, such as word processing.
o Types of application create with visual basic.NET
o Visual basic.NET- allows to develop different types of
application.
o Types of application /program that create with visual
basic.NET:
1. Windows application
o program with graphical user interface that runs in the
windows environment.
– Has a Windows user interface
– Runs on a personal computer
o User interface: what the user sees and interacts with
when using an application
2. Web application
oA program that a user accesses through a web

browser.
– Has a Web user interface
– Runs on a server
3. Console application
oA program that run in a text environment such as

the windows MS-DOS or command prompt interface.


o Visual basic .NET allows developers to create windows
applications with a graphical user interface.
o windows graphical user interface provides visual cues
such as menus, button, and icons that allows a user to
enter data and instruction into a computer .
o Both windows and console application are called stand-
alone application .
o A stand –alone application is an application that does not
requires other applications or data sources to run in the
operating system.
o Visual Basic 2010 is an object-oriented programming
language.
Object: anything that can be seen, touched, or used.
Class: a pattern used to create an object.
Instance: an object created from a class; object is said to be
instantiated.
Integrated Development Environment (IDE):
– Contains all the tools and features needed to create,
run, and test programs
– Includes Visual Basic, Visual C++, Visual C#.
o Is the visual studio development environment that used to
create and test the project.
o Consists various tools including:-
• form designer - which allow to create a form.
• Editor:-for entering and modifying programming code.
• Compiler- for translating the Visual Basic statements into
the intermediate machine code.
• Debugger- which help to locate and correct program errors.
• Object browser – which enables to view the available
classes, objects, properties, methods, and events.
o NB in visual studio. NET only one IDE is used to create
projects in any of .NET languages.
o The full version of Visual Studio 2010 provides an option
which allow the programmer to select the default profile of
the IDE.
o You may observe Default environment Settings dialog box
when opening visual studio for the first
o Then you must select the default environment settings for
a Visual Basic developer.
o Look the following picture for more clarification.
o Windows applications consist of solutions, projects, and
files.
o Solution: a container that stores projects and files for an
entire application
o Project: a container that stores files associated with a
specific portion of the solution.
o A solution may contain one or more projects.
Figure 2-1: Illustration of a solution, project, and file
1. Click the start button then point to all programs.
2. If you are using visual studio 2010 ,click Microsoft visual studio
2010 on the all programs menu, and then Microsoft visual
studio 2010.
How to Create a Visual Basic 2010 Windows Application
1. Click file in the menu bar and then click new project.
2. Click visual basic in the installed templates list and then click
windows form application.name
3. Enter an appropriate name and location in the name and
location boxes.
4. Enter an appropriate name in the solution name box.
5. Click ok button.
Figure 2-2: Visual Studio 2010 Professional startup screen
Figure 2-3: Solution and Visual Basic Project
o Windows Form Designer window:
◦ Allows you to create (design) the GUI.
o Graphical user interface (GUI):
◦ What the user sees and interacts with
o Windows Form object (or form):
◦ Foundation for the user interface.
◦ Add other objects such as buttons/text boxes to form.
◦ Title bar with caption and Minimize, Maximize, and
Close buttons.
◦ Tab at top of designer window has Form1.vb [Design]
Figure 2-4: Windows Form Designer window
o Solution Explorer window:
◦ Displays a list of projects contained in this solution.
◦ Displays the items contained in each project.

Figure 2-5: Solution Explorer window


o Properties: a set of attributes that determine an object’s
appearance and behavior.
o Properties window: displays properties of selected
object.
o Default property values are assigned when an object is
created.
o Properties window includes an Object box and a
Properties list.
o Object box:
 Located immediately below Properties window title bar.
 Contains the name of the selected object
o Properties list:
• Left column displays names of properties
• Use the Alphabetical or Categorized buttons to sort the
display of properties
o Settings box: Right column containing the current value of
each property.
o Class definition: block of code that defines the attributes
and behaviors of an object. Namespace: defines a group of
related classes
o Name property: used to refer to an object in code.
o Text property: controls the caption displayed on form’s
title bar.
o Font: general shape of characters in text
Figure 2-6: Properties window showing a partial listing of the form’s
properties
o Toolbox:
◦ Contains objects that can be added to other objects, such
as a form.
◦ Each tool has an icon and a name to identify it.
◦ Each tool represents a class from which objects, called
controls, can be created.
o Controls:
◦ Objects displayed on a form
◦ Represented as icons in the toolbox
 Controls on a form can be selected, sized, moved,
deleted, locked in place on the form and unlocked
Figure 2-7: Toolbox window
o How to add a control to a form
1. Click a tool in the toolbox, but do not release the mouse
button.
2. Hold down the mouse button as you drag the mouse
pointer to the form.
3. Release the mouse button.

Additional ways
• Double click a tool in the toolbox.
o Events: user actions while program is running.
Examples: clicking, double-clicking, scrolling
o Event procedure: set of instructions to be processed

when an event occurs.


–Tells the object how to respond to an event.
o Code editor window: used to enter event procedure’s

code.
o Ho to open the code Editors window

1.Right click the form, and then click view code on the
context menu.
Additional ways
1. Double the form or a control on the form.
Figure 2-8: Code Editor window
o Class statement: used to define a class
◦ Begins with Public Class <class name>
◦ Ends with End Class
o Class Name list box: lists the names of objects (controls)
included in the user interface.
o Method Name list box: lists the events to which the
selected object is capable of responding.
o When you select a control from the Class Name list box
and a method name, a code template for the event appears
in the Code Editor window.
 Syntax: rules of the language.
o Keyword: a word with special meaning in a programming
language.
o Event code template has a procedure header and a
procedure footer.
o Event’s procedure header:
– Begins with keywords Private Sub
– Procedure name includes Object name and Event name.
– Handles clause indicates for which objects’ events this
code will execute.
o Sub procedure: block of code that performs a task.
Figure 2-9: Code template for the exitButton’s Click event procedure
o Me.Close()instruction: closes the current form at run
time.
◦ If the current form is the only form, the application is
terminated.
o Me keyword: refers to the current form.
o Method: predefined VB procedure that can be invoked
(called) when needed.
o Sequential processing: each line is executed in sequence.
◦ Also called a sequence structure.
Figure 2-10: Me.Close() instruction entered in the Click event
procedure
o An asterisk appears on the designer and Code
Editor tabs if a change was made since the last
time the solution was saved.
o How to save a solution
• click file on the menu bar and click save all.
• click the save all button on the standard toolbar.
o Starting and Ending an Application
• Startup form: the form to be displayed when the
application starts.
o How to start an application
1. save the solution. Click debug on the menu bar, and then
click start debugging.
2. Save the solution, then press the F5 key on your keyboard.
o When you start a VB application, the IDE creates an
executable file
o Executable file:
– Can be run outside of Visual Studio 2010
– Has a file extension of .exe
– Stored in the project’s bin\Debug folder
o How to end an application.
• Click an exit button in the interface.
• Click file on the application’s menu bar, and then click Exit.
• Click the close button on the applications title bar.
• Click the stop debugging button.
o Closing the Current Solution
• Closing a solution closes all projects and files in that
solution. You are prompted to save any files that have
unsaved changes.
o How to close a solution
1. click file on the menu bar
2. click close solution
o Only one solution can be open at any one time.
o If a solution is already open, opening a different one will
close the currently open solution.
o How to open an existing solution
• Click file on the menu bar, and then click open project to
open project dialog box.
o Bug: an error in a program’s code.
o Debugging: the process of locating and correcting bugs in a
program.
o Syntax error: occurs when you break one of the
programming language’s rules.
◦ Most syntax errors are caused by typing errors.
o Rest the mouse pointer on the mistyped instruction to see
details about the error.
Figure 2-11: Syntax error in the exitButton’s Click event
procedure
o Syntax errors should be corrected before starting an
application.
o If you start an application with a syntax error, a dialog box
appears.
– Click No to open the Error List window.

Figure 2-12: Dialog box


Figure 2-13: Syntax error message
Coding Errors (cont’d.)

Figure 2-14: Result of starting an application that contains a


syntax error
o Visual Basic has three distinct modes.
1.Design time
2.Run time
3.Debug time
• Design time

The time when designing the user interface and writing


code.
• Run time

The time When testing and running your project.


• Debug time

The time if you get a run-time error or pause program


execution.
SDI and MDI Forms
o A program that can only support one open window or a
document.
o Create one instance of a particular form.
o SDIs can open only a single document at a time.
o For Example, paint and Notepad are SDI’s
o Notepad is an example of an SDI application (If you want
multiple documents open, you simply run Notepad multiple
times.) 
o Although Notepad is text-based, an SDI can be any type of
application: text, graphics, spreadsheet, anything.
o Therefore, to create an SDI, start from a normal form, add a
menu to it, and configure it to do what you want.
Single Document Interface (SDI)
o MDI programs enable users to edit multiple documents at
once.
o Usually more complex than single-document-interface
applications.
o EX. Photoshop ,Excel and Adobe Acrobat Reader are MDI’s.

Multiple Document Interface


(MDI)

MDI parent and MDI child.


o The application window of an MDI program is called the
parent window.
o Each window inside the application is referred to as a child
window.
o MDI:-Allows multiple windows
• Parent window- Application window
- Can have many child windows
• Child window- Cannot be parent
– Has exactly one parent
– Cannot be moved outside parent
– Functionality can be different than other child windows
from same parent.
Single Document Interface (SDI) Multiple Document Interface (MDI)
o You can use three different types of forms in an MDI
application.
1. An MDI parent form: acts as the container for the MDI
child forms in the solution.
2. An MDI child form: always appears inside the visible
region of its MDI parent form.
- A project may have one or more MDI child forms.
3. Standard forms: can be displayed anywhere on the screen
and are not contained by the MDI parent form.
-Standard forms are typically displayed as dialog boxes.
o MDI child forms can not be extended beyond the visible
region of the containing MDI parent form.
o Iconified MDI child forms do not appear on the task bar.
o Menus of MDI parent and MDI child forms are integrated.
How to create MDI form?
o To create MDI form, create a new form and set its
IsMDIContainer property to True. The form will then
change appearance.
◦ Create a new Form, set its IsMDIContainer property to
true.
◦ Create a child form class to be added to form
 Select Project | Add Windows Form … name the file.
◦ To add the child form to parent, in a parent’s event
handler
 Set child’s MDIParent property to parent form.
 Call method Show.
• Code to create MDI child form appears in MDI parent form.
• Create the child form instance
Dim frmCurrentChild As New frmMdiChild

• Designate the form as a child form


frmCurrentChild.MdiParent = Me

• Display the child form


frmCurrentChild.Show()
Common MDI Child
Properties
IsMdiChild Indicates whether the Form is an MDI child. (read-only)
MdiParent Specifies the MDI parent Form of the child.
Common MDI Parent
Properties
ActiveMdiChild Returns the Form that is the currently active MDI child
(returns null if no children are active).
IsMdiContainer Indicates whether a Form can be an MDI parent. Default is
False.
MdiChildren Returns the MDI children as an array of Forms.
Common Method
LayoutMdi Determines the display of child forms on an MDI parent.
Takes as a parameter an enumeration with possible values
ArrangeIcons, Cascade, TileHorizontal and
TileVertical.
Common Event
MdiChildActivate Generated when an MDI child is closed or activated.
o Child windows can be minimized, maximized and closed
independently of each other and of the parent window.
o When the parent is minimized or closed, the child windows
are minimized or closed as well.
o MDI containers allow developers to organize the
placement of child windows.
o The child windows in an MDI application can be arranged

by calling method LayoutMdi of the parent form.


o Method LayoutMdi takes a LayoutMdi enumeration,

which can have values ArrangeIcons, Cascade,


TileHorizontal and TileVertical.
Menu Item Enumerated Value
o Tile Horizontal Layout.TileHorizontal
o Tile Vertical MdiLayout.TileVertical
o Cascade MdiLayout.Cascade
o Arrange Icons MdiLayout.ArrangeIcons
o ArrangeIcons:- iconified MDI child windows are arranged
along the bottom of the MDI parent form.
o Cascade: visible MDI child windows are arranged such
that each MDI child window appears below another MDI
child window and is indented.
o TileHorizontal: divides the MDI child forms horizontally
to fill the visible region of the MDI parent form.
o TileVertical: divides the MDI child forms vertically to fill
the visible region of the MDI parent form
1. Double-click the MainMenu tool in the Toolbox window to
add a new object named MainMenu1 to the form tray.
2. At the top of the MDI parent form, click the box with Type
Here in it and type &File.
3. Press Enter to move to the next menu item and
type &Products.
4. Press Enter and type E&xit.
oEach MDI parent form and any MDI child form in a solution
can have its own menu system.
MDI application menus have unique characteristics
– One menu bar appears below the title bar of the MDI
parent form.
– An MDI parent form’s menu appears when no MDI child
forms are loaded.
– When an instance of an MDI child form is loaded or has
focus, the menu of the MDI parent form is merged with
the menu of the MDI child form
o Menus of MDI parent and MDI child forms are merged
based on the following property values:
• Merge Order property
– Applies to a Menu Item and contains an Integer value.
– Indicates the relative order in which two menus or menu
items will be merged.
• Merge Type property
– Works in conjunction with the Merge Order property.
– Defines whether one menu will replace another menu,
whether one menu will be added to another menu, or
whether menu items will be merged together.
o The MergeType property has a data type of MenuMerge.
Possible enumeration values
1. Add - menu on the MDI child form will be added to the
menu of the MDI parent form.
2. MergeItems - menu items on the MDI child form menu will
be merged with the menu items on the MDI parent form
menu.
3. Remove - MDI parent form menu or menu item will not
appear in the merged menu.
4. Replace - causes the menu of the MDI child form to replace
the menu appearing on the MDI parent form
o To select and display an MDI child form from a menu
◦ Set the MdiList property of a menu item to True
 This setting causes the menu item to display a list of MDI child
form instances.
 The caption appearing in the menu is the same as the caption
appearing in the title bar of the MDI child form.
 The process is automatic - you need not write any statements
to display the MDI child forms.
o An object is a type of user interface element you create
on a Visual Basic form by using a toolbox control.
o In Visual Basic, the form itself is an object.
o Every Visual Basic control consists of three important
elements:
o Properties: which describe the object,
o Methods: cause an object to do something and
o Events: are what happens when an object does something.
o All the Visual Basic Objects can be moved, resized or
customized by setting their properties.
o A property is a value or characteristic held by a Visual

Basic object, such as Caption or Fore Color.


o Properties can be set at design time by using the

Properties window or at run time by using statements in


the program code.
Object . Property = Value
Where,
Object: is the name of the object you're customizing.
Property: is the characteristic you want to change.
Value: is the new property setting
o VB.Net provides a huge variety of controls that help you to
create rich user interface.
o Functionalities of all these controls are defined in the
respective control classes.
o The control classes are defined in the
System.Windows.Forms namespace.
o Forms: The container for all the controls that make up
the user interface.
o TextBox:
• It represents a Windows text box control.
• When user want to type some input use a text box.
• used to add text or to display text in a form.
o The following are some of the commonly used properties
of the TextBox control:
 CharacterCasing: Gets or sets whether the TextBox
control modifies the case of characters as they are typed.
 Font: Gets or sets the font of the text displayed by the
control.
 ForeColor: Gets or sets the foreground color of the
control.
 Lines: Gets or sets the lines of text in a text box control.
 Multiline Gets or sets a value indicating whether this is a
multiline TextBox control.
6.PasswordChar: Gets or sets the character used to mask
characters of a password in a single-line TextBox control.
7. ReadOnly: Gets or sets a value indicating whether text in
the textbox is read-only.
8. Text: Gets or sets the current text in the TextBox.
9. TextAlign Gets or sets how text is aligned in a TextBox
control. This property has values:
Left
Right
Center
10. AutoSize: Enables automatic resizing based on font size
for single-line edit controls.
o The following are some of the commonly used methods of
the TextBox control:
1. AppendText: Appends text to the current text of a text box.

2. Clear: Clears all text from the text box control.

3. Copy: Copies the current selection in the text box to the


Clipboard.
4. Cut: Moves the current selection in the text box to the
Clipboard.
5. Paste: Replaces the current selection in the text box with
the contents of the Clipboard.
6. Undo: Undoes the last edit operation in the text box.
o The following are some of the commonly used events of the Text
control:
1. Click: Occurs when the control is clicked.
2. DoubleClick: Occurs when the control is double-clicked.
3. TextAlignChanged: Occurs when the TextAlign property value
changes.
o Label:
• It represents a standard Windows label.
• is usually used to display text that cannot be edited by the user
during runtime.
• But using the properties or code that is displayed can be
changed.
o The following are some of the commonly used properties
of the Label control:
1.Autosize: Gets or sets a value specifying if the control
should be automatically resized to display all its contents.
2. BorderStyle: Gets or sets the border style for the control.
3. Font: Gets or sets the font of the text displayed by the
control.
4. ForeColor: Gets or sets the foreground color of the
control.
5. Text: Gets or sets the text associated with this control.
6. TextAlign: Gets or sets the alignment of text in the label.
o The following are some of the commonly used methods of
the Label control:
1. Refresh: Forces the control to invalidate its client area and
immediately redraw itself and any child controls.
2. Select: Activates the control.

3. Show: Displays the control to the user.

Events of the Label Control


1. Click: Occurs when the control is clicked.
2. DoubleClick: Occurs when the control is double-clicked.

3. GotFocus: Occurs when the control receives focus.

4. TextChanged: Occurs when the Text property value


changes.
o Button:
• It represents a Windows button control.
• is used to trigger some action for the form.
• It is generally used to generate a Click event by providing a
handler for the Click event.
Properties of the Button Control
o The following are some of the commonly used properties of the Button
control:
1. AutoSizeMode: Gets or sets the mode by which the Button
automatically resizes itself.
2. BackColor: Gets or sets the background color of the control.
3. BackgroundImage: Gets or sets the background image
displayed in the control.
4. ForeColor: Gets or sets the foreground color of the control.
5. Image: Gets or sets the image that is displayed on a button
control.
6. Text: Gets or sets the text associated with this control.
oList Box:
•is used to display a list of items, from which the user can
select single or multiple choices by clicking on them.
•It allows the programmer to add items at design time by

using the properties window or at the runtime.


1. BorderStyle: Gets or sets the type of border drawn around
the list box.
2. Items: Gets the items of the list box.
3. MultiColumn: Gets or sets a value indicating whether the list
box supports multiple columns.
4. Text: Gets or searches for the text of the currently selected
item in the list box.
5. Sorted: Gets or sets a value indicating whether the items in
the list box are sorted alphabetically.
6. SelectionMode: Gets or sets the method in which items are
selected in the listbox. This property has values:
None, One MultiSimple, MultiExtended
o ComboBox:
• It represents a Windows combo box control.
• is used to display a drop-down list of various items.

• It is a combination of a text box in which the user enters an

item and a drop-down list from which the user selects an


item.
• Properties of the ComboBox Control

1. Sorted: Gets or sets a value indicating whether the items


in the combo box are sorted.
2. Text: Gets or sets the text associated with this control.
3. Items: Gets an object representing the collection of the
items contained in this ComboBox.
4. MaxDropDownItems: Gets or sets the maximum number
of items to be displayed in the drop-down part of the combo
box.
5. FlatStyle: Gets or sets the appearance of the ComboBox.
6. MaxLength: Gets or sets the maximum number of
characters a user can enter in the editable area of the combo
box.
oRadioButton:
•It
enables the user to select a single option from a group of
choices when paired with other RadioButton controls.
1. Appearance: Gets or sets a value determining the appearance of the
radio button.
2. Check Align: Gets or sets the location of the check box portion of the
radiobutton.
3. Checked: Gets or sets a value indicating whether the control is checked.
4. Text: Gets or sets the caption for a radio button.
o CheckBox:
• It represents a Windows CheckBox.
• is used to select the choice by checking or not checking a
check box.
• When a check box is selected it has the value True, and
when it is cleared, it holds the value False.
1. Appearance: Gets or sets a value determining the
appearance of the checkbox.
2. CheckAlign: Gets or sets the horizontal and vertical
alignment of the checkmark on the check box.
3. Checked: Gets or sets a value indicating whether the
check box is selected.
4. CheckState: Gets or sets the state of a check box.
5. Text: Gets or sets the caption of a check box.
o PictureBox:
• is used to display an image of the file formats like png, gif,
jpeg, bmp, wmf, ico, pcx, tga, tiff.
• Images can be loaded either at the design time or at runtime.
o Properties of the PictureBox Control
1. Image: Gets or sets the image that is displayed in the control.
2. Initial Image: Gets or sets the image displayed in the control
when the main image is loaded.
3. SizeMode: Determines the size of the image to be displayed in
control. Normal, StrechImage, AutoSize,CenterImage, Zoom
• It represents a Windows progress bar control.
• It is used to provide visual feedback to your users about

the status of some task.


• It shows a bar that fills in from left to right as the

operation.
Properties of the ProgressBar Control
1. Font: Gets or sets the font of text in the ProgressBar.

2. Value: Gets/ sets the current position of the progress bar.

3. Maximum: maximum value of the range of the control.

4. Minimum: minimum value of the range of the control.

5. MarqueeAnimationSpeed: Gets or sets the time period, in


milliseconds,
o ScrollBar:
 The ScrollBar controls display vertical and horizontal scroll
bars on the form.
 This is used for navigating through large amount of
information.
 There are two types of scroll bar controls:
 HScrollBar: for horizontal scroll bars and VScrollBar: for
vertical scroll bars.
 These are used independently from each other.
1. Value: Gets or sets a numeric value that represents the
current position of the scroll box on the scroll bar control.
2. Maximum: Gets or sets the upper limit of values of the
scrollable range.
3. Minimum: Gets or sets the lower limit of values of the
scrollable range.
4. LargeChange: Gets or sets a value to be added to or
subtracted from the Value property when the scroll box
is moved a large distance.
5. SmallChange: Gets or sets the value to be added to or
subtracted from the Value property when the scroll box is
moved a small distance.
o DateTimePicker:
• The DateTimePicker control allows selecting a date and
time by editing the displayed values in the control.
• If you click the arrow in the DateTimePicker control, it
displays a month calendar, like a combo box control.
• The user can make selection by clicking the required date.
• The new selected value appears in the text box part of the
control.
1. CalendarFont: Gets or sets the font style applied to the
calendar.
2. CalendarForeColor: Gets or sets the foreground color of the
calendar.
3. CalendarMonthBackground: Gets or sets the background
color of the calendar month.
4. CalendarTitleBackColor: Gets or sets the background color
of the calendar title.
5. CalendarTitleForeColor: Gets or sets the foreground color
of the calendar title.
6. Format: Gets or sets the format of the date and time
displayed in the control.
o TreeView:
• It displays a hierarchical collection of labeled items, each
represented by a TreeNode.
o Rich TextBox:
• RichTextBox Control is used to display an image of the file
formats like png, gif, jpeg, bmp, wmf, ico, pcx, tga, tiff.
Images can be loaded either at the design time or at
runtime.
o TIMER:
 Timer Control is used to set time intervals, this control is
visible only at design time and not in the runtime.
o Imagelist:
 ImageList Control is used to store images that can be used
with other controls. This control works fine with the
controls that have the ImageList and ImageIndex property.
o Tooltip:
 Tooltip Control is used to display explanatory text when
the mouse rest on a control or window. This control is
helpful in providing a quick help to users.

You might also like