SlideShare une entreprise Scribd logo
1  sur  32
 Forms
 Form properties
 Controls
 Control properties
 Event Driven Programming
 Form Events
 Control Events
 Event Handlers
 VB Example Program
 A form is a container for controls
 A form is used to design a GUI-based window
in aWindows application
 A form displays information and receives
input from the user.
 Always orient a form at a task as defined by
the user
 Text – defines the text to display in the caption bar
 StartPosition – determines position of form when it
first appears (eg. CenterScreen)
 Size.Width, Size.Height – the 2D area occupied by
the form, in units of pixels
 Location.X, Location.Y – the relative position of the
form on the screen
 Visible – can be seen by the user
 Enabled – the user can interact with the form
 FormBorderStyle – determines the appearance and
behavior of the borders of the form
 Sizable: (Default) Has min, max, and close buttons; can be
resized by dragging edges
 Fixed 3D: Has a 3D look; min, max, and close buttons;
cannot be resized
 FixedSingle: Has single line border; min, max, and close
buttons; cannot be resized
 AcceptButton - designates which button on the
form is activated by the Enter Key
 Cancel Button - designates which button on the
form is activated by the ESC Key
 Visual objects that are placed on a form to enable
customized activities
 FamiliarVisual Basic controls:
 Label - displays text the user cannot change
 TextBox - allows the user to enter text
 Button – performs an action when clicked
 RadioButton - A round button that is selected or deselected with a mouse
 CheckBox – A box that is checked or unchecked with a mouse click
 Form - A window that contains these controls
 Built-in controls defined inWindows Form class library,
and are defined
 withToolBox and Form Designer
 or strictly with code
 Common properties shared by many controls
 Name,Text
 Size.Height &Width, Location.X &Y, Dock
 BackColor: Sets the background (fill) color
 ForeColor: Sets the foreground (text) color
 CanFocus, ContainsFocus, Focused
 Visible & Enabled determine availability to user
 Font properties affect text display in the control
▪ Font, size, bold, etc.
 Tab Index &Tab Stop
 DesignTime  Set in
PropertiesWindow
 RunTime  Set / Change in
Code
Slide 2- 9
 Specify the control name (btnExit)
 Then a dot
 Then the PropertyName (Visible)
 controlName.propertyName
 btnExit.Visible
▪ refers to theVisible property of the btnExit control
▪ The visible property values may only be true or false
 Item to receive the value (Left Side)
 Assignment Indicator =
 Value to be assigned(Right Side)
 VariableName =Value
 NumberVariable = 5
 ControlName.PropertyName = Setting
 btnExit.Visible = False
▪ Assigns the value False to theVisible property of the btnExit control
▪ Causes the text of the btnExit control to become hidden to the user
 txtFirstName.text = “Paul”
 txtLastName.text = “Overstreet”
 Properties
 Text
▪ &Cancel -> Cancel
▪ && -> &
 Events
 Click
 Use labels and link labels for text
display
 Text property (no more Caption) defines
text to display
 User cannot change a label
 LinkLabel enables hyperlinks
 Links.Add inserts a hyperlink into text
 Must write event-handler to invoke
browser
 See example
 Text box allows user to
enter or edit data
 Properties
 MaxLength, MultiLine
 AcceptsTab
 AcceptsReturn
 WordWrap
 ScrollBars
 Events
 TextChanged
 CheckState property
 Checked
 Unchecked
 Indeterminate (checked
but grayed)
 Text property displays
built-in caption
If chkMarried.CheckState = CheckState.Checked Then
M
End If
 ComboBox Properties
 Text
 DropDownStyle
▪ Simple
▪ Dropdown
▪ DropdownList
 Sorted
 Methods
 Items.Clear
 Items.Add
 Items.Remove
cboChoice.Items.Clear()
cboChoice.Items.Add("First")
cboChoice.Items.Add("Second")
cboChoice.Items.Add("Third")
cboChoice.Items.Add(TextBox1.Text)
cboChoice.Items.Remove("Third")
 Executes code after a
specified interval
 Timer Event
 Unique event that executes
after the interval specified in
the interval property expires
 Interval Property
 0 - 65,535 milliseconds
▪ 0 - means disabled
▪ 60,000 milliseconds is one
minute
 Enabled property must also
be true for timer to work.
 Timer control is never
visible at run time
 Stored in ComponentTray
at design time
 Applications recognize and respond to events by
executing code known as event procedures
 Event: An action that is recognized by an object.
 User Actions
▪ Mouse Click
▪ EnteringText
▪ Pressing a Key
 Program Calculations
 Triggered by the system
▪ Timer
 Event Handler: Code that is written by the
programmer to respond to an event
 Executes only when particular event occurs
 Common Form Events
 Form1_Load() - Occurs before a form is displayed
for the first time.
 Form1_Activated() - Occurs when form becomes
the active window - through code or by user
 Form1_Deactivate() - Occurs when the form loses
focus and is not the active form
 Form1_Closing() - Occurs when the form closes,
either through an event or the windows close
button being clicked
 Many controls share a Common set of events
to which they can react
 Click, DoubleClick
 MouseMove, MouseDown, MouseUp,
MouseWheel, MouseHover, MouseLeave
 KeyPress, KeyDown, KeyUp
 Resize
 DragDrop
 GotFocus
 LostFocus
 Focus is when an object becomes the “Active
Control”
 Focus Event Sequence:
 Enter
 GotFocus
 Leave
 Validating
 Validated
 LostFocus
 Create Event Procedure
 Double Click on Control
 Displays CodeWindow and Event Procedure Stub for
default event
Or
 Open the Code Editor (F7 orView Menu:Code Command)
 Select Control & Event from drop down windows in Code
Editor
Event Code Goes In Here
Exit Button – Clicked Method (btnExit_Click)
Private Sub btnExit_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnExit.Click
' End the application
End
End Sub
Line Continuation Mark
Name of the event the procedure responds to
Name of the control that owns the event procedure
Marks the beginning of this event procedure
Ends the program
Event handled by this procedure
 Input
 Controls
 Process
 Events
 Output
 Controls
UDIE – Implement the solution inVB:
 Create the Interface
 Input Controls
 Output Controls
 Set the Properties
 Configure the appearance and behavior of the
controls
 Write the Code to execute when events occur
 Process the inputs to create the outputs
 UsingVisual Basic.Net
create the following form
Object Property Setting
Form1 Text Demonstration
txtFirst Text (blank)
txtSecond Text (blank)
btnRed Text Change Color
to Red
When btnRed is clicked - Change txtFirst text color to red
 Double Click on btnRed
 Code window should appear
(with Event Procedure Stub)
 Add code to the event procedure stub:
txtFirst.ForeColor = Color.Red
When the text is edited in txtFirst - Change txtFirst text color to blue
 In CodeWindow
 Select the Control for the Event Procedure
 txtFirst from the ClassName box
 Select the Event from the Method Name Box
 TextChanged
 Add code to the event procedure stub:
 txtFirst.ForeColor = Color.Blue
When txtFirst is deselected - Change txtFirst text color to black
 In CodeWindow
 Select the Control for the Event Procedure
 txtFirst from the ClassName box
 Select the Event from the Method Name Box
 Leave
 Add code to the event procedure stub:
 txtFirst.ForeColor = Color.Black
 Click F5 or the Run Button
 Type “Hello” into the 1st textbox
 What Happens
 Click on the 2nd Textbox
 What happened in txtFirst and Why
 Click on the Button
 What happened in txtFirst
 Type “Friends” into the 1st textbox
 Stop Program by clicking Red X in corner
 Add a Button to your Form
 Name: btnExit
 Text Property: &Quit
 Add a Button Click Event for this Button
 Code: END
 Finds Syntax Errors (Errors in Programming Language)
 Return to btnRed Click Event Procedure
 Add this line of Code:
 txtSecond.text = Hello
Notice Wavy Blue Line –This indicates a Syntax Error that must be fixed.

Contenu connexe

Tendances

Master pages
Master pagesMaster pages
Master pagesteach4uin
 
javascript objects
javascript objectsjavascript objects
javascript objectsVijay Kalyan
 
Procedures functions structures in VB.Net
Procedures  functions  structures in VB.NetProcedures  functions  structures in VB.Net
Procedures functions structures in VB.Nettjunicornfx
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivityTanmoy Barman
 
Windows form application_in_vb(vb.net --3 year)
Windows form application_in_vb(vb.net --3 year)Windows form application_in_vb(vb.net --3 year)
Windows form application_in_vb(vb.net --3 year)Ankit Gupta
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScriptShahDhruv21
 
visual basic v6 introduction
visual basic v6 introductionvisual basic v6 introduction
visual basic v6 introductionbloodyedge03
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And MultithreadingShraddha
 
Visual Programming
Visual ProgrammingVisual Programming
Visual ProgrammingBagzzz
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript ObjectsReem Alattas
 
Database connectivity to sql server asp.net
Database connectivity to sql server asp.netDatabase connectivity to sql server asp.net
Database connectivity to sql server asp.netHemant Sankhla
 
VB Function and procedure
VB Function and procedureVB Function and procedure
VB Function and procedurepragya ratan
 
Exception Handling in VB.Net
Exception Handling in VB.NetException Handling in VB.Net
Exception Handling in VB.Netrishisingh190
 
Visual Basic IDE Introduction
Visual Basic IDE IntroductionVisual Basic IDE Introduction
Visual Basic IDE IntroductionAhllen Javier
 

Tendances (20)

Visual Basic Controls ppt
Visual Basic Controls pptVisual Basic Controls ppt
Visual Basic Controls ppt
 
Master pages
Master pagesMaster pages
Master pages
 
javascript objects
javascript objectsjavascript objects
javascript objects
 
Procedures functions structures in VB.Net
Procedures  functions  structures in VB.NetProcedures  functions  structures in VB.Net
Procedures functions structures in VB.Net
 
Introduction to DOM
Introduction to DOMIntroduction to DOM
Introduction to DOM
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
Windows form application_in_vb(vb.net --3 year)
Windows form application_in_vb(vb.net --3 year)Windows form application_in_vb(vb.net --3 year)
Windows form application_in_vb(vb.net --3 year)
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
 
visual basic v6 introduction
visual basic v6 introductionvisual basic v6 introduction
visual basic v6 introduction
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
 
Visual Programming
Visual ProgrammingVisual Programming
Visual Programming
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript Objects
 
Web controls
Web controlsWeb controls
Web controls
 
Database connectivity to sql server asp.net
Database connectivity to sql server asp.netDatabase connectivity to sql server asp.net
Database connectivity to sql server asp.net
 
VB Function and procedure
VB Function and procedureVB Function and procedure
VB Function and procedure
 
Core java slides
Core java slidesCore java slides
Core java slides
 
Exception Handling in VB.Net
Exception Handling in VB.NetException Handling in VB.Net
Exception Handling in VB.Net
 
C program
C programC program
C program
 
Array in c#
Array in c#Array in c#
Array in c#
 
Visual Basic IDE Introduction
Visual Basic IDE IntroductionVisual Basic IDE Introduction
Visual Basic IDE Introduction
 

Similaire à Controls events

4.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.154.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.15Rajes Wari
 
06 win forms
06 win forms06 win forms
06 win formsmrjw
 
Windows Forms For Beginners Part 5
Windows Forms For Beginners Part 5Windows Forms For Beginners Part 5
Windows Forms For Beginners Part 5Bhushan Mulmule
 
Spf chapter 03 WinForm
Spf chapter 03 WinFormSpf chapter 03 WinForm
Spf chapter 03 WinFormHock Leng PUAH
 
Session 1. Bai 1 ve winform
Session 1. Bai 1 ve winformSession 1. Bai 1 ve winform
Session 1. Bai 1 ve winformmrtom16071980
 
Windows form application - C# Training
Windows form application - C# Training Windows form application - C# Training
Windows form application - C# Training Moutasm Tamimi
 
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAMPROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAMSaraswathiRamalingam
 
Practicalfileofvb workshop
Practicalfileofvb workshopPracticalfileofvb workshop
Practicalfileofvb workshopdhi her
 

Similaire à Controls events (20)

4.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.154.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.15
 
06 win forms
06 win forms06 win forms
06 win forms
 
Windows Forms For Beginners Part 5
Windows Forms For Beginners Part 5Windows Forms For Beginners Part 5
Windows Forms For Beginners Part 5
 
Spf chapter 03 WinForm
Spf chapter 03 WinFormSpf chapter 03 WinForm
Spf chapter 03 WinForm
 
4.C#
4.C#4.C#
4.C#
 
Session 1. Bai 1 ve winform
Session 1. Bai 1 ve winformSession 1. Bai 1 ve winform
Session 1. Bai 1 ve winform
 
Visual studio.net
Visual studio.netVisual studio.net
Visual studio.net
 
Chapter 02
Chapter 02Chapter 02
Chapter 02
 
Unit2
Unit2Unit2
Unit2
 
WPF Controls
WPF ControlsWPF Controls
WPF Controls
 
Windows form application - C# Training
Windows form application - C# Training Windows form application - C# Training
Windows form application - C# Training
 
Visualbasic tutorial
Visualbasic tutorialVisualbasic tutorial
Visualbasic tutorial
 
SPF WinForm Programs
SPF WinForm ProgramsSPF WinForm Programs
SPF WinForm Programs
 
Ch01
Ch01Ch01
Ch01
 
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAMPROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
 
Intake 38 9
Intake 38 9Intake 38 9
Intake 38 9
 
Vb6.0 intro
Vb6.0 introVb6.0 intro
Vb6.0 intro
 
Ppt lesson 03
Ppt lesson 03Ppt lesson 03
Ppt lesson 03
 
Vb introduction.
Vb introduction.Vb introduction.
Vb introduction.
 
Practicalfileofvb workshop
Practicalfileofvb workshopPracticalfileofvb workshop
Practicalfileofvb workshop
 

Dernier

Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 

Dernier (20)

Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 

Controls events

  • 1.
  • 2.  Forms  Form properties  Controls  Control properties  Event Driven Programming  Form Events  Control Events  Event Handlers  VB Example Program
  • 3.  A form is a container for controls  A form is used to design a GUI-based window in aWindows application  A form displays information and receives input from the user.  Always orient a form at a task as defined by the user
  • 4.  Text – defines the text to display in the caption bar  StartPosition – determines position of form when it first appears (eg. CenterScreen)  Size.Width, Size.Height – the 2D area occupied by the form, in units of pixels  Location.X, Location.Y – the relative position of the form on the screen  Visible – can be seen by the user  Enabled – the user can interact with the form
  • 5.  FormBorderStyle – determines the appearance and behavior of the borders of the form  Sizable: (Default) Has min, max, and close buttons; can be resized by dragging edges  Fixed 3D: Has a 3D look; min, max, and close buttons; cannot be resized  FixedSingle: Has single line border; min, max, and close buttons; cannot be resized  AcceptButton - designates which button on the form is activated by the Enter Key  Cancel Button - designates which button on the form is activated by the ESC Key
  • 6.  Visual objects that are placed on a form to enable customized activities  FamiliarVisual Basic controls:  Label - displays text the user cannot change  TextBox - allows the user to enter text  Button – performs an action when clicked  RadioButton - A round button that is selected or deselected with a mouse  CheckBox – A box that is checked or unchecked with a mouse click  Form - A window that contains these controls  Built-in controls defined inWindows Form class library, and are defined  withToolBox and Form Designer  or strictly with code
  • 7.  Common properties shared by many controls  Name,Text  Size.Height &Width, Location.X &Y, Dock  BackColor: Sets the background (fill) color  ForeColor: Sets the foreground (text) color  CanFocus, ContainsFocus, Focused  Visible & Enabled determine availability to user  Font properties affect text display in the control ▪ Font, size, bold, etc.  Tab Index &Tab Stop
  • 8.  DesignTime  Set in PropertiesWindow  RunTime  Set / Change in Code
  • 9. Slide 2- 9  Specify the control name (btnExit)  Then a dot  Then the PropertyName (Visible)  controlName.propertyName  btnExit.Visible ▪ refers to theVisible property of the btnExit control ▪ The visible property values may only be true or false
  • 10.  Item to receive the value (Left Side)  Assignment Indicator =  Value to be assigned(Right Side)  VariableName =Value  NumberVariable = 5  ControlName.PropertyName = Setting  btnExit.Visible = False ▪ Assigns the value False to theVisible property of the btnExit control ▪ Causes the text of the btnExit control to become hidden to the user  txtFirstName.text = “Paul”  txtLastName.text = “Overstreet”
  • 11.  Properties  Text ▪ &Cancel -> Cancel ▪ && -> &  Events  Click
  • 12.  Use labels and link labels for text display  Text property (no more Caption) defines text to display  User cannot change a label  LinkLabel enables hyperlinks  Links.Add inserts a hyperlink into text  Must write event-handler to invoke browser  See example
  • 13.  Text box allows user to enter or edit data  Properties  MaxLength, MultiLine  AcceptsTab  AcceptsReturn  WordWrap  ScrollBars  Events  TextChanged
  • 14.  CheckState property  Checked  Unchecked  Indeterminate (checked but grayed)  Text property displays built-in caption If chkMarried.CheckState = CheckState.Checked Then M End If
  • 15.  ComboBox Properties  Text  DropDownStyle ▪ Simple ▪ Dropdown ▪ DropdownList  Sorted  Methods  Items.Clear  Items.Add  Items.Remove cboChoice.Items.Clear() cboChoice.Items.Add("First") cboChoice.Items.Add("Second") cboChoice.Items.Add("Third") cboChoice.Items.Add(TextBox1.Text) cboChoice.Items.Remove("Third")
  • 16.  Executes code after a specified interval  Timer Event  Unique event that executes after the interval specified in the interval property expires  Interval Property  0 - 65,535 milliseconds ▪ 0 - means disabled ▪ 60,000 milliseconds is one minute  Enabled property must also be true for timer to work.  Timer control is never visible at run time  Stored in ComponentTray at design time
  • 17.  Applications recognize and respond to events by executing code known as event procedures  Event: An action that is recognized by an object.  User Actions ▪ Mouse Click ▪ EnteringText ▪ Pressing a Key  Program Calculations  Triggered by the system ▪ Timer  Event Handler: Code that is written by the programmer to respond to an event  Executes only when particular event occurs
  • 18.  Common Form Events  Form1_Load() - Occurs before a form is displayed for the first time.  Form1_Activated() - Occurs when form becomes the active window - through code or by user  Form1_Deactivate() - Occurs when the form loses focus and is not the active form  Form1_Closing() - Occurs when the form closes, either through an event or the windows close button being clicked
  • 19.  Many controls share a Common set of events to which they can react  Click, DoubleClick  MouseMove, MouseDown, MouseUp, MouseWheel, MouseHover, MouseLeave  KeyPress, KeyDown, KeyUp  Resize  DragDrop  GotFocus  LostFocus
  • 20.  Focus is when an object becomes the “Active Control”  Focus Event Sequence:  Enter  GotFocus  Leave  Validating  Validated  LostFocus
  • 21.  Create Event Procedure  Double Click on Control  Displays CodeWindow and Event Procedure Stub for default event Or  Open the Code Editor (F7 orView Menu:Code Command)  Select Control & Event from drop down windows in Code Editor Event Code Goes In Here
  • 22. Exit Button – Clicked Method (btnExit_Click) Private Sub btnExit_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnExit.Click ' End the application End End Sub Line Continuation Mark Name of the event the procedure responds to Name of the control that owns the event procedure Marks the beginning of this event procedure Ends the program Event handled by this procedure
  • 23.  Input  Controls  Process  Events  Output  Controls
  • 24. UDIE – Implement the solution inVB:  Create the Interface  Input Controls  Output Controls  Set the Properties  Configure the appearance and behavior of the controls  Write the Code to execute when events occur  Process the inputs to create the outputs
  • 25.  UsingVisual Basic.Net create the following form Object Property Setting Form1 Text Demonstration txtFirst Text (blank) txtSecond Text (blank) btnRed Text Change Color to Red
  • 26. When btnRed is clicked - Change txtFirst text color to red  Double Click on btnRed  Code window should appear (with Event Procedure Stub)  Add code to the event procedure stub: txtFirst.ForeColor = Color.Red
  • 27. When the text is edited in txtFirst - Change txtFirst text color to blue  In CodeWindow  Select the Control for the Event Procedure  txtFirst from the ClassName box  Select the Event from the Method Name Box  TextChanged
  • 28.  Add code to the event procedure stub:  txtFirst.ForeColor = Color.Blue
  • 29. When txtFirst is deselected - Change txtFirst text color to black  In CodeWindow  Select the Control for the Event Procedure  txtFirst from the ClassName box  Select the Event from the Method Name Box  Leave  Add code to the event procedure stub:  txtFirst.ForeColor = Color.Black
  • 30.  Click F5 or the Run Button  Type “Hello” into the 1st textbox  What Happens  Click on the 2nd Textbox  What happened in txtFirst and Why  Click on the Button  What happened in txtFirst  Type “Friends” into the 1st textbox  Stop Program by clicking Red X in corner
  • 31.  Add a Button to your Form  Name: btnExit  Text Property: &Quit  Add a Button Click Event for this Button  Code: END
  • 32.  Finds Syntax Errors (Errors in Programming Language)  Return to btnRed Click Event Procedure  Add this line of Code:  txtSecond.text = Hello Notice Wavy Blue Line –This indicates a Syntax Error that must be fixed.