SlideShare a Scribd company logo
1 of 35
CIS 115 Lecture 3
 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 a Windows 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
 Fixed3D: 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
 Familiar Visual 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 in Windows Form class library,
and are defined
 with ToolBox and Form Designer
 or strictly with code
 Text edit (TextBox—txt___)
 Text display (Label—default name or lbl___)
 Selection from a list (ListBox—lst___, ComboBox—cbo___,
ListView, TreeView, NumericUpDown…)
 Graphic display (PictureBox—pic___)
 Graphic storage (ImageList)
 Value setting (CheckBox—chk___, CheckListBox, RadioButton,…)
 Date setting (DateTimePicker, MonthCalendar)
 Dialog boxes (OpenFileDialog, PrintDialog…)
 Menu controls (MainMenu, …)
 Commands (Button—btn___, LinkLabel…)
 Grouping other controls (GroupBox, TabControl, Panel)
 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
Design Time  Set in
Properties Window
Run Time  Set / Change in
Code
Slide 2- 10
 Specify the control name (btnExit)
 Then a dot
 Then the PropertyName (Visible)
 controlName.propertyName
 btnExit.Visible
▪ refers to the Visible 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 the Visible 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

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 Component Tray 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
▪ Entering Text
▪ 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 Code Window and Event Procedure Stub for
default event
Or
 Open the Code Editor (F7 or View 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 in VB:
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
 Using Visual Basic.Net
create the following form
ObjectObject PropertyProperty SettingSetting
Form1Form1 TextText DemonstrationDemonstration
txtFirsttxtFirst TextText (blank)(blank)
txtSecondtxtSecond TextText (blank)(blank)
btnRedbtnRed TextText Change ColorChange Color
to Redto 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 Code Window
Select the Control for the Event Procedure
 txtFirst from the ClassName box
Select the Event from the Method Name Box
 TextChanged
Class Nam
e
Box
M
ethod
Nam
e
Box
Add code to the event procedure stub:
 txtFirst.ForeColor = Color.Blue
When txtFirst is deselected - Change txtFirst text color to black
In Code Window
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.
Test All Events
Click Quit Button
 Homework 1
 Visual Basic Controls and Properties
 See handout for details and due date
 Questions?

More Related Content

What's hot

Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3Bhushan Mulmule
 
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
 
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAMPROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAMSaraswathiRamalingam
 
Spf chapter 03 WinForm
Spf chapter 03 WinFormSpf chapter 03 WinForm
Spf chapter 03 WinFormHock Leng PUAH
 
VB.Net-Controls and events
VB.Net-Controls and eventsVB.Net-Controls and events
VB.Net-Controls and eventsPrachi Sasankar
 
Buttons In .net Visual Basic
Buttons In .net Visual BasicButtons In .net Visual Basic
Buttons In .net Visual Basicmanish maurya
 
Session 3 Bai 3 ve winform
Session 3 Bai 3 ve winformSession 3 Bai 3 ve winform
Session 3 Bai 3 ve winformmrtom16071980
 
Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6Jeanie Arnoco
 
Computer homework
Computer homeworkComputer homework
Computer homeworkadarsh-kaul
 
Session 2 Bai 2 ve winform
Session 2 Bai 2 ve winformSession 2 Bai 2 ve winform
Session 2 Bai 2 ve winformmrtom16071980
 
Vb6 ch.6-3 cci
Vb6 ch.6-3 cciVb6 ch.6-3 cci
Vb6 ch.6-3 cciFahim Khan
 
Gui programming a review - mixed content
Gui programming   a review - mixed contentGui programming   a review - mixed content
Gui programming a review - mixed contentYogesh Kumar
 

What's hot (20)

SPF WinForm Programs
SPF WinForm ProgramsSPF WinForm Programs
SPF WinForm Programs
 
Visual C# 2010
Visual C# 2010Visual C# 2010
Visual C# 2010
 
Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3
 
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)
 
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAMPROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
 
Spf chapter 03 WinForm
Spf chapter 03 WinFormSpf chapter 03 WinForm
Spf chapter 03 WinForm
 
Vs c# lecture1
Vs c# lecture1Vs c# lecture1
Vs c# lecture1
 
VB.Net-Controls and events
VB.Net-Controls and eventsVB.Net-Controls and events
VB.Net-Controls and events
 
Chapter 02
Chapter 02Chapter 02
Chapter 02
 
Vs c# lecture3
Vs c# lecture3Vs c# lecture3
Vs c# lecture3
 
Vs c# lecture2
Vs c# lecture2Vs c# lecture2
Vs c# lecture2
 
Buttons In .net Visual Basic
Buttons In .net Visual BasicButtons In .net Visual Basic
Buttons In .net Visual Basic
 
Vs c# lecture5
Vs c# lecture5Vs c# lecture5
Vs c# lecture5
 
Session 3 Bai 3 ve winform
Session 3 Bai 3 ve winformSession 3 Bai 3 ve winform
Session 3 Bai 3 ve winform
 
Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6
 
Computer homework
Computer homeworkComputer homework
Computer homework
 
Session 2 Bai 2 ve winform
Session 2 Bai 2 ve winformSession 2 Bai 2 ve winform
Session 2 Bai 2 ve winform
 
Ingles 2do parcial
Ingles   2do parcialIngles   2do parcial
Ingles 2do parcial
 
Vb6 ch.6-3 cci
Vb6 ch.6-3 cciVb6 ch.6-3 cci
Vb6 ch.6-3 cci
 
Gui programming a review - mixed content
Gui programming   a review - mixed contentGui programming   a review - mixed content
Gui programming a review - mixed content
 

Similar to 4.7.14&17.7.14&23.6.15&10.9.15

Similar to 4.7.14&17.7.14&23.6.15&10.9.15 (20)

Controls events
Controls eventsControls events
Controls events
 
Visualbasic tutorial
Visualbasic tutorialVisualbasic tutorial
Visualbasic tutorial
 
WPF Controls
WPF ControlsWPF Controls
WPF Controls
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Java
 
Visual studio.net
Visual studio.netVisual studio.net
Visual studio.net
 
Mca 504 dotnet_unit5
Mca 504 dotnet_unit5Mca 504 dotnet_unit5
Mca 504 dotnet_unit5
 
Csphtp1 12
Csphtp1 12Csphtp1 12
Csphtp1 12
 
Unit2
Unit2Unit2
Unit2
 
Intake 38 9
Intake 38 9Intake 38 9
Intake 38 9
 
Windows Programming with AWT
Windows Programming with AWTWindows Programming with AWT
Windows Programming with AWT
 
Chapter 3.2
Chapter 3.2Chapter 3.2
Chapter 3.2
 
Vb6.0 intro
Vb6.0 introVb6.0 intro
Vb6.0 intro
 
engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.ppt
 
visual basic v6 introduction
visual basic v6 introductionvisual basic v6 introduction
visual basic v6 introduction
 
3.5 the controls object
3.5   the controls object3.5   the controls object
3.5 the controls object
 
Ppt lesson 03
Ppt lesson 03Ppt lesson 03
Ppt lesson 03
 
Android basics – dialogs and floating activities
Android basics – dialogs and floating activitiesAndroid basics – dialogs and floating activities
Android basics – dialogs and floating activities
 
Intake 37 9
Intake 37 9Intake 37 9
Intake 37 9
 
Treinamento Qt básico - aula III
Treinamento Qt básico - aula IIITreinamento Qt básico - aula III
Treinamento Qt básico - aula III
 
Practicalfileofvb workshop
Practicalfileofvb workshopPracticalfileofvb workshop
Practicalfileofvb workshop
 

More from Rajes Wari

c++ INTRODUCTION SOFTWARE CROISIS TYPES OF PRO
c++ INTRODUCTION SOFTWARE CROISIS TYPES OF PROc++ INTRODUCTION SOFTWARE CROISIS TYPES OF PRO
c++ INTRODUCTION SOFTWARE CROISIS TYPES OF PRORajes Wari
 
11.3.14&22.1.16
11.3.14&22.1.1611.3.14&22.1.16
11.3.14&22.1.16Rajes Wari
 
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++Rajes Wari
 

More from Rajes Wari (7)

c++ INTRODUCTION SOFTWARE CROISIS TYPES OF PRO
c++ INTRODUCTION SOFTWARE CROISIS TYPES OF PROc++ INTRODUCTION SOFTWARE CROISIS TYPES OF PRO
c++ INTRODUCTION SOFTWARE CROISIS TYPES OF PRO
 
10.8.2018
10.8.201810.8.2018
10.8.2018
 
12.7.2018
12.7.201812.7.2018
12.7.2018
 
11.3.14&22.1.16
11.3.14&22.1.1611.3.14&22.1.16
11.3.14&22.1.16
 
25.2.14
25.2.1425.2.14
25.2.14
 
18.2.14
18.2.1418.2.14
18.2.14
 
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++
 

Recently uploaded

Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 

Recently uploaded (20)

Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 

4.7.14&17.7.14&23.6.15&10.9.15

  • 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 a Windows 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  Fixed3D: 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  Familiar Visual 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 in Windows Form class library, and are defined  with ToolBox and Form Designer  or strictly with code
  • 7.  Text edit (TextBox—txt___)  Text display (Label—default name or lbl___)  Selection from a list (ListBox—lst___, ComboBox—cbo___, ListView, TreeView, NumericUpDown…)  Graphic display (PictureBox—pic___)  Graphic storage (ImageList)  Value setting (CheckBox—chk___, CheckListBox, RadioButton,…)  Date setting (DateTimePicker, MonthCalendar)  Dialog boxes (OpenFileDialog, PrintDialog…)  Menu controls (MainMenu, …)  Commands (Button—btn___, LinkLabel…)  Grouping other controls (GroupBox, TabControl, Panel)
  • 8.  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
  • 9. Design Time  Set in Properties Window Run Time  Set / Change in Code
  • 10. Slide 2- 10  Specify the control name (btnExit)  Then a dot  Then the PropertyName (Visible)  controlName.propertyName  btnExit.Visible ▪ refers to the Visible property of the btnExit control ▪ The visible property values may only be true or false
  • 11. 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 the Visible property of the btnExit control ▪ Causes the text of the btnExit control to become hidden to the user  txtFirstName.text = “Paul”  txtLastName.text = “Overstreet”
  • 12.  Properties  Text ▪ &Cancel -> Cancel ▪ && -> &  Events  Click
  • 13.  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
  • 14.  Text box allows user to enter or edit data  Properties  MaxLength, MultiLine  AcceptsTab  AcceptsReturn  WordWrap  ScrollBars  Events  TextChanged
  • 15.  CheckState property  Checked  Unchecked  Indeterminate (checked but grayed)  Text property displays built-in caption If chkMarried.CheckState = CheckState.Checked Then  End If
  • 16.  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")
  • 17.  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 Component Tray at design time
  • 18.  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 ▪ Entering Text ▪ 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
  • 19. 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
  • 20.  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
  • 21.  Focus is when an object becomes the “Active Control”  Focus Event Sequence:  Enter  GotFocus  Leave  Validating  Validated  LostFocus
  • 22.  Create Event Procedure  Double Click on Control  Displays Code Window and Event Procedure Stub for default event Or  Open the Code Editor (F7 or View Menu:Code Command)  Select Control & Event from drop down windows in Code Editor Event Code Goes In Here
  • 23. 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
  • 25. UDIE – Implement the solution in VB: 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
  • 26.  Using Visual Basic.Net create the following form ObjectObject PropertyProperty SettingSetting Form1Form1 TextText DemonstrationDemonstration txtFirsttxtFirst TextText (blank)(blank) txtSecondtxtSecond TextText (blank)(blank) btnRedbtnRed TextText Change ColorChange Color to Redto Red
  • 27. 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
  • 28. When the text is edited in txtFirst - Change txtFirst text color to blue In Code Window Select the Control for the Event Procedure  txtFirst from the ClassName box Select the Event from the Method Name Box  TextChanged Class Nam e Box M ethod Nam e Box
  • 29. Add code to the event procedure stub:  txtFirst.ForeColor = Color.Blue
  • 30. When txtFirst is deselected - Change txtFirst text color to black In Code Window 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
  • 31. 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
  • 32. Add a Button to your Form  Name: btnExit  Text Property: &Quit Add a Button Click Event for this Button  Code: END
  • 33.  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.
  • 35.  Homework 1  Visual Basic Controls and Properties  See handout for details and due date  Questions?

Editor's Notes

  1. Code is from INPUT.FRM, Function GET_PK