SlideShare a Scribd company logo
Session 1
Trình bày : Võ Ngọc Đạt
Email : vongocdatit@gmail.com
Điện thoại : 0934.969.680
Slide 1 of 3809/20/13
Windows Forms and Basic Controls
Slide 2 of 2609/20/13
This module provides an overview of Windows Forms and the basic controls used to
create graphical user interfaces.
Module Introduction
A Windows Form is a window used to hold various controls.
These controls are graphical objects that facilitate user interaction to accept data or to
display information.
Slide 3 of 3809/20/13
Windows Forms
Windows Forms allows the developer to create user interfaces using various built-in
components.
The applications created using Windows Forms are executed on the local machine. The
form can access the resources of the local machine such as memory, printer, folders, and
files.
The role of Windows Forms include:
+ Holding controls
+ Handling user input
+ Displaying information
+ Connecting to database, which might exists
on another machine
Slide 4 of 3809/20/13
Windows Forms in .NET Framework
Slide 5 of 3809/20/13
"Form" Class
- The basic unit of an application is a form.
- A form is a container that holds and manages controls and is
used to create GUI based Windows applications.
- A Windows Form application will have at least one form
(window)
- Create a form in an application by creating an object of
the Form class
System.Windows. Form namespace.
Session 1. Bai 1 ve winform
Slide 7 of 3809/20/13
Property Description
ForeColor Specifies or retrieves the foreground color.
Location Specifies or retrieves the co-ordinates of the upper left corner of the form.
Modal Specifies or retrieves a value indicating whether the form is shown modally. This means if the user tries to
activate another window or form, the user cannot do so without closing the current modal form.
WindowState Specifies or retrieves a value indicating whether a form is minimized, maximized, or is in the normal state.
Method Description
Activate Activates a form and gives it focus.
Focus Puts the focus on a control.
Event Description
Activated Occurs when the form is activated in code or by the user.
Click Occurs when a control in clicked.
Deactivate Occurs when the focus on the form is taken away in code or by the user.
FormClosed Occurs after the form is closed.
GotFocus Occurs when the focus is put on a control of the form.
Resize Occurs when a control on the form is resized.
Validated Occurs when validation is completed by a control. For example, the event is raised after validating the login
details in the TextBox control.
Slide 8 of 3809/20/13
Slide 9 of 3809/20/13
Lifecycle of Windows Forms
Slide 10 of 3809/20/13
Types of Controls
Microsoft Visual Studio provides different types of controls for Windows Forms
programming.
Slide 11 of 3809/20/13
Types
A control is associated with its respective built-in class defined in the System.Windows.Forms
namespace.
For example, the Label control is associated with the Label class.
Each control class consists of various properties, methods, and events
Slide 12 of 3809/20/13
"Control" Class
The Control class is the base class of all the controls
The class is defined in System.Windows.Forms namespace and defines various properties,
methods, and events.
Slide 13 of 3809/20/13
Slide 14 of 3809/20/13
Property Description
Controls Retneves a collection of controls contained within the control.
Name Specifies or retrieves the name of a control.
Parent Specifies or retrieves the parent container of the control.
Method Description
Focus Sets input focus to the control.
Hide Hides the control from the user.
Select Activates a control.
Show Displays the control.
Event Description
Click Occurs when a control is clicked.
ControlAdded Occurs when a new control is added to the Control .
Doubleclick Occurs when the control is double-clicked.
GotFocus Occurs when the focus is on the control.
Leave Occurs when the input focus leaves the control.
LostFocus Occurs when the control loses focus.
Move Occurs when the user moves the control.
TextChanged Occurs when the value of the Text property changes.
Slide 15 of 3809/20/13
"Label" Control
- The Label control is a control that is used to show detailed information, which cannot be
modified by the user.
- The most common purpose of the Label control is to provide captions to the controls
Slide 16 of 3809/20/13
"TextBox" Controls
- The TextBox control takes the required information from the user, which can be modified.
For example, you can create a TextBox control to accept the name of the student.
Property Description
CharacterCasing Specifies whether the characters should be converted to uppercase or lowercase.
MaxLength Specifies or retrieves the maximum number of characters that the user can enter in
the control.
MultiLine Specifies or retrieves a value indicating whether the user can enter multi-line text.
Name Specifies or retrieves the name of the control.
PasswordChar Specifies or retrieves the special character used to mask characters of a password.
Readonly Specifies or retrieves a value whether the text in the control is editable.
Text Specifies or retrieves the text on the control.
Slide 17 of 3809/20/13
Method Description
AppendText Adds text to the existing text of the control.
Clear Removes text from the control.
Copy Copies the selected text in the control to the Clipboard.
Focus Sets the input focus on the control to enter text.
Paste Replaces the selected text in the control with the text copied to the Clipboard.
Event Description
KeyPress Occurs when the user has finished pressing a key.
Leave Occurs when the control is no longer the active control of the form.
TextChanged Occurs when the value of the Text property changes.
Slide 18 of 3809/20/13
Property Description
Mask Specifies or retrieves the characters to be used as a mask.
MaskCompleted Retrieves a value indicating whether the user has entered all the required
characters into the input mask.
Name Specifies or retrieves the name of the control.
PromptChar Specifies or retrieves the character to be used for prompting the user if the user
has missed some input.
Text Specifies or retrieves the text on the control.
"MaskedTextBox" Controls
- The MaskedTextBox control is a new control used to validate user input.
Slide 19 of 3809/20/13
"Button" Control
The Button control provides the easiest way to allow the user to interact with an application.
The user can click the button to perform the required action.
Slide 20 of 3809/20/13
Property Description
DialogResult Specifies or retrieves a value which is sent to the parent form when a button is
clicked.
Enabled Specifies or retrieves a value indicating whether the control can be accessed by the
user.
FlatStyle Specifies or retrieves the flat style of the control, which can be Flat, standard, Popup,
or System.
Image Specifies or retrieves the image on the control.
Name Specifies or retrieves the name of the control.
Text Specifies or retrieves the text on the control.
Method Description
Focus Sets the focus on the control.
PerformClick Triggers a Click event for a button.
Event Description
Click Occurs when the control is clicked.
Doubleclick Occurs when the control is double-clicked.
MouseDoubleClick Occurs when the control is double-clicked using the mouse.
Slide 21 of 3809/20/13
"ListBox" and "ComboBox" Controls
- The ListBox control is a control used to select a single value or multiple values from the given
list of values.
- The ComboBox control is similar to the ListBox control, but it allows you to select only one
value at a time.
Slide 22 of 3809/20/13
Property Description
Items Retrieves the items of the control.
SelectionMode Specifies or retrieves the way in which items are selected in the control, which can be:
+ None: For not selecting any item
+ One: For single selection
+ MultiSimple: For multiple selections
+ MultiExtended: For multiple selections using the Shift + Mouse click, Shift+ Arrow
keys, or Ctrl+ Mouse click.
Selectedlndex Specifies or retrieves the zero-based index number of the selected item in the control.
Text Specifies or retrieves the text of the selected item in the control.
Method Description
ClearSelected Deselects all the selected items in the control.
GetltemText Retrieves the text of the given item.
GetSelected Returns true if the specified item is selected and returns false if the specified item is not
selected.
SetSelected Selects or removes the selection for a specified item.
Event Description
SelectedlndexChanged Occurs when the value of the Selectedlndex property is modified.
SelectedValueChanged Occurs when the value of the SelectedValue property is modified.
"ListBox" Controls
Slide 23 of 3809/20/13
Slide 24 of 3809/20/13
"ComboBox" Controls
Property Description
DropDownStyle Specifies or retrieves a value indicating the style of the control. The appearance of the
control can be changed to Simple, DropDown, and DropDownList styles.
Items Retrieves the object containing the items of the control.
MaxDropDownItems Specifies or retrieves the maximum number of items to be displayed in the control.
Selectedltem Specifies or retrieves the selected item in the control.
Selectedlndex Specifies or retrieves the zero-based index number of the selected item in the control.
Text Specifies or retrieves the text of the control.
Method Description
GetltemText Gets the text of the given item.
SelectAll Selects the text appearing in the control.
Select Activates a control and is inherited from the Control class.
Event Description
DropDown Occurs when the drop-down portion of the control is displayed.
SelectedlndexChanged Occurs when the value of the selectedlndex property is modified.
SelectedValueChanged Occurs when the value of the SelectedValue property is modified.
Slide 25 of 3809/20/13
Slide 26 of 3809/20/13
"LinkLabel" Control
- The LinkLabel control is similar to the Label control, but allows you to display its caption as a
hyperlink.

More Related Content

PPT
4.7.14&17.7.14&23.6.15&10.9.15
PPT
Session 2 Bai 2 ve winform
PPTX
Windows form application - C# Training
DOCX
Visual C# 2010
PPT
PPTX
Windowforms controls c#
PPT
Session 3 Bai 3 ve winform
PPTX
Windows form application_in_vb(vb.net --3 year)
4.7.14&17.7.14&23.6.15&10.9.15
Session 2 Bai 2 ve winform
Windows form application - C# Training
Visual C# 2010
Windowforms controls c#
Session 3 Bai 3 ve winform
Windows form application_in_vb(vb.net --3 year)

What's hot (19)

PPTX
Controls events
PPTX
Spf chapter 03 WinForm
PPT
Visual basic 6.0
PDF
Intake 38 8
PDF
Step bystep abap_field help or documentation
PDF
Visualbasic tutorial
PPT
Creating a quiz using visual basic 6
DOC
Visual basic
DOCX
PPTX
User define data type In Visual Basic
PDF
Chapter 10.1.4
PDF
Ingles 2do parcial
PPTX
Graphical User Interface (Gui)
PDF
Form personalization 395117_r12_updated1212
PDF
Vb 6ch123
PDF
Step by step abap_input help or lov
PPT
Graphical User Interface in JAVA
DOC
Advance communication system manual
PDF
Vb6 ch.8-3 cci
Controls events
Spf chapter 03 WinForm
Visual basic 6.0
Intake 38 8
Step bystep abap_field help or documentation
Visualbasic tutorial
Creating a quiz using visual basic 6
Visual basic
User define data type In Visual Basic
Chapter 10.1.4
Ingles 2do parcial
Graphical User Interface (Gui)
Form personalization 395117_r12_updated1212
Vb 6ch123
Step by step abap_input help or lov
Graphical User Interface in JAVA
Advance communication system manual
Vb6 ch.8-3 cci
Ad

Similar to Session 1. Bai 1 ve winform (20)

PDF
VB.Net-Controls and events
PPTX
unit3.2 (1).pptx
PPT
WPF Controls
PPTX
Vb6.0 intro
PPT
Android Application Development Programming
DOCX
data binding.docx
PPSX
PPTX
CheckBox In C#.pptx
PPT
XPages Workshop: Concepts And Exercises
PDF
Intake 38 9
PPT
C# Tutorial MSM_Murach chapter-10-slides
PPT
Combo box and List box in VB.Net.ppt
PPT
Qtp Training
DOC
Practicalfileofvb workshop
DOCX
Lab StepsSTEP 1 Login Form1. In order to do this lab, we need.docx
PPT
Csphtp1 12
PPTX
How To Open The Form View Of Many2many Clicking Tag In Odoo 18
PPTX
Mobile Application Development((Handling User Input and Navigation) class-05
PPTX
Using macros in microsoft access
VB.Net-Controls and events
unit3.2 (1).pptx
WPF Controls
Vb6.0 intro
Android Application Development Programming
data binding.docx
CheckBox In C#.pptx
XPages Workshop: Concepts And Exercises
Intake 38 9
C# Tutorial MSM_Murach chapter-10-slides
Combo box and List box in VB.Net.ppt
Qtp Training
Practicalfileofvb workshop
Lab StepsSTEP 1 Login Form1. In order to do this lab, we need.docx
Csphtp1 12
How To Open The Form View Of Many2many Clicking Tag In Odoo 18
Mobile Application Development((Handling User Input and Navigation) class-05
Using macros in microsoft access
Ad

More from mrtom16071980 (8)

PPTX
Bai giang-ms-excel-2010
PPTX
7314 l10 pwerpoint
PPT
hoc ve xml
PPT
Session 8 Bai 8 ve winform
PPT
Session 6 Bai 6 ve winform
PPT
Session 5 Bai 5 ve winform
PPT
Session 4 Bai 4 ve winform
PPT
Session 7 Bai 7 ve winform
Bai giang-ms-excel-2010
7314 l10 pwerpoint
hoc ve xml
Session 8 Bai 8 ve winform
Session 6 Bai 6 ve winform
Session 5 Bai 5 ve winform
Session 4 Bai 4 ve winform
Session 7 Bai 7 ve winform

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Approach and Philosophy of On baking technology
PPTX
sap open course for s4hana steps from ECC to s4
PPT
Teaching material agriculture food technology
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
20250228 LYD VKU AI Blended-Learning.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
MYSQL Presentation for SQL database connectivity
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
MIND Revenue Release Quarter 2 2025 Press Release
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Review of recent advances in non-invasive hemoglobin estimation
Spectral efficient network and resource selection model in 5G networks
Network Security Unit 5.pdf for BCA BBA.
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Digital-Transformation-Roadmap-for-Companies.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Approach and Philosophy of On baking technology
sap open course for s4hana steps from ECC to s4
Teaching material agriculture food technology
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf

Session 1. Bai 1 ve winform

  • 1. Session 1 Trình bày : Võ Ngọc Đạt Email : vongocdatit@gmail.com Điện thoại : 0934.969.680 Slide 1 of 3809/20/13 Windows Forms and Basic Controls
  • 2. Slide 2 of 2609/20/13 This module provides an overview of Windows Forms and the basic controls used to create graphical user interfaces. Module Introduction A Windows Form is a window used to hold various controls. These controls are graphical objects that facilitate user interaction to accept data or to display information.
  • 3. Slide 3 of 3809/20/13 Windows Forms Windows Forms allows the developer to create user interfaces using various built-in components. The applications created using Windows Forms are executed on the local machine. The form can access the resources of the local machine such as memory, printer, folders, and files. The role of Windows Forms include: + Holding controls + Handling user input + Displaying information + Connecting to database, which might exists on another machine
  • 4. Slide 4 of 3809/20/13 Windows Forms in .NET Framework
  • 5. Slide 5 of 3809/20/13 "Form" Class - The basic unit of an application is a form. - A form is a container that holds and manages controls and is used to create GUI based Windows applications. - A Windows Form application will have at least one form (window) - Create a form in an application by creating an object of the Form class System.Windows. Form namespace.
  • 7. Slide 7 of 3809/20/13 Property Description ForeColor Specifies or retrieves the foreground color. Location Specifies or retrieves the co-ordinates of the upper left corner of the form. Modal Specifies or retrieves a value indicating whether the form is shown modally. This means if the user tries to activate another window or form, the user cannot do so without closing the current modal form. WindowState Specifies or retrieves a value indicating whether a form is minimized, maximized, or is in the normal state. Method Description Activate Activates a form and gives it focus. Focus Puts the focus on a control. Event Description Activated Occurs when the form is activated in code or by the user. Click Occurs when a control in clicked. Deactivate Occurs when the focus on the form is taken away in code or by the user. FormClosed Occurs after the form is closed. GotFocus Occurs when the focus is put on a control of the form. Resize Occurs when a control on the form is resized. Validated Occurs when validation is completed by a control. For example, the event is raised after validating the login details in the TextBox control.
  • 8. Slide 8 of 3809/20/13
  • 9. Slide 9 of 3809/20/13 Lifecycle of Windows Forms
  • 10. Slide 10 of 3809/20/13 Types of Controls Microsoft Visual Studio provides different types of controls for Windows Forms programming.
  • 11. Slide 11 of 3809/20/13 Types A control is associated with its respective built-in class defined in the System.Windows.Forms namespace. For example, the Label control is associated with the Label class. Each control class consists of various properties, methods, and events
  • 12. Slide 12 of 3809/20/13 "Control" Class The Control class is the base class of all the controls The class is defined in System.Windows.Forms namespace and defines various properties, methods, and events.
  • 13. Slide 13 of 3809/20/13
  • 14. Slide 14 of 3809/20/13 Property Description Controls Retneves a collection of controls contained within the control. Name Specifies or retrieves the name of a control. Parent Specifies or retrieves the parent container of the control. Method Description Focus Sets input focus to the control. Hide Hides the control from the user. Select Activates a control. Show Displays the control. Event Description Click Occurs when a control is clicked. ControlAdded Occurs when a new control is added to the Control . Doubleclick Occurs when the control is double-clicked. GotFocus Occurs when the focus is on the control. Leave Occurs when the input focus leaves the control. LostFocus Occurs when the control loses focus. Move Occurs when the user moves the control. TextChanged Occurs when the value of the Text property changes.
  • 15. Slide 15 of 3809/20/13 "Label" Control - The Label control is a control that is used to show detailed information, which cannot be modified by the user. - The most common purpose of the Label control is to provide captions to the controls
  • 16. Slide 16 of 3809/20/13 "TextBox" Controls - The TextBox control takes the required information from the user, which can be modified. For example, you can create a TextBox control to accept the name of the student. Property Description CharacterCasing Specifies whether the characters should be converted to uppercase or lowercase. MaxLength Specifies or retrieves the maximum number of characters that the user can enter in the control. MultiLine Specifies or retrieves a value indicating whether the user can enter multi-line text. Name Specifies or retrieves the name of the control. PasswordChar Specifies or retrieves the special character used to mask characters of a password. Readonly Specifies or retrieves a value whether the text in the control is editable. Text Specifies or retrieves the text on the control.
  • 17. Slide 17 of 3809/20/13 Method Description AppendText Adds text to the existing text of the control. Clear Removes text from the control. Copy Copies the selected text in the control to the Clipboard. Focus Sets the input focus on the control to enter text. Paste Replaces the selected text in the control with the text copied to the Clipboard. Event Description KeyPress Occurs when the user has finished pressing a key. Leave Occurs when the control is no longer the active control of the form. TextChanged Occurs when the value of the Text property changes.
  • 18. Slide 18 of 3809/20/13 Property Description Mask Specifies or retrieves the characters to be used as a mask. MaskCompleted Retrieves a value indicating whether the user has entered all the required characters into the input mask. Name Specifies or retrieves the name of the control. PromptChar Specifies or retrieves the character to be used for prompting the user if the user has missed some input. Text Specifies or retrieves the text on the control. "MaskedTextBox" Controls - The MaskedTextBox control is a new control used to validate user input.
  • 19. Slide 19 of 3809/20/13 "Button" Control The Button control provides the easiest way to allow the user to interact with an application. The user can click the button to perform the required action.
  • 20. Slide 20 of 3809/20/13 Property Description DialogResult Specifies or retrieves a value which is sent to the parent form when a button is clicked. Enabled Specifies or retrieves a value indicating whether the control can be accessed by the user. FlatStyle Specifies or retrieves the flat style of the control, which can be Flat, standard, Popup, or System. Image Specifies or retrieves the image on the control. Name Specifies or retrieves the name of the control. Text Specifies or retrieves the text on the control. Method Description Focus Sets the focus on the control. PerformClick Triggers a Click event for a button. Event Description Click Occurs when the control is clicked. Doubleclick Occurs when the control is double-clicked. MouseDoubleClick Occurs when the control is double-clicked using the mouse.
  • 21. Slide 21 of 3809/20/13 "ListBox" and "ComboBox" Controls - The ListBox control is a control used to select a single value or multiple values from the given list of values. - The ComboBox control is similar to the ListBox control, but it allows you to select only one value at a time.
  • 22. Slide 22 of 3809/20/13 Property Description Items Retrieves the items of the control. SelectionMode Specifies or retrieves the way in which items are selected in the control, which can be: + None: For not selecting any item + One: For single selection + MultiSimple: For multiple selections + MultiExtended: For multiple selections using the Shift + Mouse click, Shift+ Arrow keys, or Ctrl+ Mouse click. Selectedlndex Specifies or retrieves the zero-based index number of the selected item in the control. Text Specifies or retrieves the text of the selected item in the control. Method Description ClearSelected Deselects all the selected items in the control. GetltemText Retrieves the text of the given item. GetSelected Returns true if the specified item is selected and returns false if the specified item is not selected. SetSelected Selects or removes the selection for a specified item. Event Description SelectedlndexChanged Occurs when the value of the Selectedlndex property is modified. SelectedValueChanged Occurs when the value of the SelectedValue property is modified. "ListBox" Controls
  • 23. Slide 23 of 3809/20/13
  • 24. Slide 24 of 3809/20/13 "ComboBox" Controls Property Description DropDownStyle Specifies or retrieves a value indicating the style of the control. The appearance of the control can be changed to Simple, DropDown, and DropDownList styles. Items Retrieves the object containing the items of the control. MaxDropDownItems Specifies or retrieves the maximum number of items to be displayed in the control. Selectedltem Specifies or retrieves the selected item in the control. Selectedlndex Specifies or retrieves the zero-based index number of the selected item in the control. Text Specifies or retrieves the text of the control. Method Description GetltemText Gets the text of the given item. SelectAll Selects the text appearing in the control. Select Activates a control and is inherited from the Control class. Event Description DropDown Occurs when the drop-down portion of the control is displayed. SelectedlndexChanged Occurs when the value of the selectedlndex property is modified. SelectedValueChanged Occurs when the value of the SelectedValue property is modified.
  • 25. Slide 25 of 3809/20/13
  • 26. Slide 26 of 3809/20/13 "LinkLabel" Control - The LinkLabel control is similar to the Label control, but allows you to display its caption as a hyperlink.