Unit 2
Unit 2
BUILDING WINDOWS
APPLICATIONS
Methods
A method is an action that an object can perform.
For example, Add is a method of the ComboBox
object, because it adds a new entry to a combo
box.
The following procedure uses the Add method to
add a new item to a ComboBox.
Sub ChangeName(newTitle)
myForm.Caption = newTitle
End Sub
Events
An event is an action recognized by an object,
such as clicking the mouse or pressing a key, and
for which you can write code to respond.
Events can occur as a result of a user action or
program code, or they can be triggered by the
system.
Most common events are: click, keydown,
keypress, mousemove, mouseclick etc.
EVENT HANDLING
Events are basically a user action like key press, clicks, mouse
movements, etc., or some occurrence like system generated
notifications. Applications need to respond to events when they
occur.
Clicking on a button, or entering some text in a text box, or
clicking on a menu item, all are examples of events. An event
is an action that calls a function or may cause another event.
Event handlers are functions that tell how to respond to an
event.
VB.Net is an event-driven language. There are mainly two
types of events −
Mouse events
Keyboard events
Handling Mouse Events
Mouse events occur with mouse movements in forms and
controls. Following are the various mouse events related with
a Control class −
8 Text The text, which will appear at the title bar of the form.
4 KeyDown Occurs when a key is pressed while the form has focus.
5 KeyPress Occurs when a key is pressed while the form has focus.
6 KeyUp Occurs when a key is released while the form has focus.
8 MouseDown Occurs when the mouse pointer is over the form and a
mouse button is pressed.
9 MouseEnter Occurs when the mouse pointer enters the form.
10 MouseMove Occurs when the mouse pointer is moved over the form.
11 MouseUp Occurs when the mouse pointer is over the form and a
mouse button is released.
TEXTBOX
Properties of the TextBox Control
S.N Property Description
1 Font Gets or sets the font of the text displayed by the control.
8 TextAlign Gets or sets how text is aligned in a TextBox control. This property
has values: Left, Right and Center
9 Name Name of textbox control.
Events of the TextBox Control
S.N Event Description
1 Click Occurs when the control is clicked.
2 DoubleClick Occurs when the control is double-clicked.
3 KeyDown Occurs when a key is pressed while the
textbox has focus.
4 KeyPress Occurs when a key is pressed while the
textbox has focus.
5 KeyUp Occurs when a key is released while the
textbox has focus.
6 LostFocus Occurs when the textbox loses focus.
LABEL
Properties of the Label Control
3 ImageLocation Gets or sets the path or the URL for the image displayed in
the control.
4 SizeMode Determines the size of the image to be displayed in the
control. This property takes its value from the
PictureBoxSizeMode enumeration, which has values:
Normal, StrechImage, AutoSize, CenterImage, Zoom.
5 Name This is the actual name of the control.
7 MouseDown Occurs when the mouse pointer is over the control and a
mouse button is pressed.
8 MouseMove Occurs when the mouse pointer is moved over the control.
9 MouseUp Occurs when the mouse pointer is over the control and a
mouse button is released.
TIMER
Properties of Timer
SN Name Description
1 Name This is the actual name of the control.
2 Enabled Gets or sets a value indicating whether the Timer should raise
the Elapsed event.
3 Interval Gets or sets the interval, expressed in milliseconds, at which to
raise the Elapsed event.
4 Modifier Indicates the visibility level of the object
SN Name Description
1 Disposed Occurs when the component is disposed by a call to the
Dispose method.
2 Tick Occurs when the timer’s time change.
LISTVIEW
Properties of the ListView Control
S.N Property Description
3 Columns Gets the collection of all column headers that appear in the
control.
4 Name This is the actual name of the control.
Ctrl + End Goes to the end of module. (Also in the Immediate window.)
Ctrl + Right Arrow Moves one word to the right.
Ctrl + Left Arrow Moves one word to the left.
End Moves to the end of the line.
Home Moves to the beginning of the line.
Ctrl + Y Deletes the current line.
Ctrl + Delete Deletes to the end of a word.
Ctrl + Shift + F9 Clears all breakpoints.
Project Explorer
F7 Shift + Opens the selected file's module.
Enter
Home Selects the first file in the list.
End Selects the last file in the list.
Right arrow Expands a sublist.
Left arrow Collapses a sublist.
Up arrow Moves up the list one item at a time.
Down arrow Moves down the list one item at a time.
End of slide