SlideShare a Scribd company logo
1 of 41
Download to read offline
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 1
CONTROLS:
An object is a type of user interface element you create on a Visual Basic form by
using a toolbox control. In fact, in Visual Basic, the form itself is an object. Every
Visual Basic control consists of three important elements −
 Properties which describe the object,
 Methods cause an object to do something and
 Events are what happened when an object does something.
Control Properties
All the Visual Basic Objects can be moved, resized or customized by setting their
properties. A property is a value or characteristic held by a Visual Basic object, such
as Caption or Fore Color.
Properties can be set at design time by using the Properties window or at run time by
using statements in the program code.
Ex: Object.Property = Value
Where
 Object is the name of the object you're customizing.
 Property is the characteristic you want to change.
 Value is the new property setting.
Control Methods
A method is a procedure created as a member of a class and they cause an object to
do something. Methods are used to access or manipulate the characteristics of an
object or a variable.
There are mainly two categories of methods you will use in your classes −
 If you are using a control such as one of those provided by the Toolbox, you can
call any of its public methods. The requirements of such a method depend on the
class being used.
 If none of the existing methods can perform your desired task, you can add a
method to a class.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 2
Ex:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
MessageBox.Show("Hello, World")
End Sub
End Class
Control Events
An event is a signal that informs an application that something important has
occurred. For example, when a user clicks a control on a form, the form can raise
a Click event and call a procedure that handles the event. There are various types of
events associated with a Form like click, double click, close, load, resize, etc.
Following is the default structure of a form Load event handler subroutine.
Ex:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'event handler code goes here
End Sub
1. Form Controls
A Form is used in VB.NET to create a form-based or window-based application.
Using the form, we can build a attractive user interface. It is like a container for
holding different control that allows the user to interact with an application. The
controls are an object in a form such as buttons, Textboxes, Textarea, labels, etc. to
perform some action. However, we can add any control to the runtime by creating an
instance of it.
Form Properties :-
The following are the most important list of properties related to a form. And these
properties can be set or read while the application is being executed.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 3
Properties Description
BackColor It is used to set the background color for the form.
BackgroundImage It is used to set the background image of the form.
Cursor It is used to set the cursor image when it hovers over
the form.
AllowDrop Using the AllowDrop control in a form, it allows
whether to drag and drop on the form.
Font It is used to get or set the font used in a form.
Locked It determines whether the form is locked or not.
FormBorderStyle It is used to set or get border style in a form.
Text It is used to set the title for a form window.
MinimizeBox MinimizeBox It is used to display the minimum
option on the title bar of the form.
IsMDIChild It is used to authenticate whether a form is a container
of a Multiple Document Interface (MDI) child form.
Autoscroll It allows whether to enable auto-scrolling in a form.
MaximizeBox It is used to display the maximum option on the title
bar of the form.
MaximumSize It is used to set the maximum height and width of the
form.
Language It is used to specifies the localized language in a form.
AcceptButton It is used to set the form button if the enter key is
pressed.
Top, Left It is used to set the top-left corner coordinates of the
form in pixel.
Name It is used to define the name of the form.
MinimumSize It is used to set the minimum height and width of the
form.
Enabled It uses the True or False value to enable mouse or
keyboard events in the form.
TopMost It uses a Boolean value that represents whether you
want to put the window form on top of the other form.
By default, it is False.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 4
Form Events :-
The following are the most important list of events related to a form.
Events Description
Activated An activated event is found when the user or
program activates the form.
Click A click event is active when the form is clicked.
Closed A closed event is found before closing the form.
Closing It exists when a form is closing.
DoubleClick DoubleClick
The DoubleClick event is activated when a user
double clicks on the form.
DragDrop A DragDrop event is activated when a drag and
drop operation is performed.
MouseDown A MouseDown event is activated when the mouse
pointer is on the form, and the mouse button is
pressed.
GotFocus A GotFocus event is activated when the form
control receives a focus.
HelpButtonClicked It is activated when a user clicked on the help
button.
KeyDown A KeyDown event is activated when a key is
pressed while focussing on the form.
KeyUp A KeyUp event is activated when a key is released
while focusing on the form.
Load The load event is used to load a form before it is
first displayed.
LostFocus It is activated when the form loses focus.
MouseEnter A MouseEnter event is activated when the mouse
pointer enters the form.
MouseHover A MouseHover event is activated when the mouse
pointer put on the form.
MouseLeave A MouseLeave event is activated when the mouse
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 5
pointer leaves the form surface.
Shown It is activated whenever the form is displayed for
the first time.
Scroll A Scroll event is activated when a form is scrolled
through a user or code.
Resize A Resize event is activated when a form is resized.
Move A Move event is activated when a form is moved.
2. Label Control
In VB.NET, a label control is used to display descriptive text for the form in control.
It does not participate in user input or keyboard or mouse events. Also, we cannot
rename labels at runtime. The labels are defined in the class System.Windows.Forms
namespace.
Label Properties :-
Properties Description
AutoSize As the name defines, an AutoSize property of label
control is used to set or get a value if it is automatically
resized to display all its contents.
Border Style It is used to set the style of the border in the Windows
form.
PreferredWidth It is used to set or get the preferred width for the Label
control.
Font It is used to get or set the font of the text displayed on a
Windows form.
PreferredHeight It is used to set the height for the Label Control.
TextAlign It is used to set the alignment of text such as centre,
bottom, top, left, or right.
ForeColor It is used to set the color of the text.
Text It is used to set the name of a label in the Windows
Form.
ContextMenu It is used to get or sets the shortcut menu associated
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 6
with the Label control.
DefaultSize It is used to get the default size of the Label control.
Image It is used to set the image to a label in Windows Form.
ImageIndex It is used to set the index value to a label control
displayed on the Windows form.
Label Events:-
Events Description
AutoSizeChanged An AutoSizeChanged event occurs in the Label
control when the value of AutoSize property is
changed.
Click Click event is occurring in the Label Control to
perform a click.
DoubleClick When a user performs a double-clicked in the Label
control, the DoubleClick event occurs.
GotFocus It occurs when the Label Control receives focus on
the Window Form.
Leave The Leave event is found when the input focus
leaves the Label Control.
TabIndexChanged It occurs when the value of Tabindex property is
changed in the Label control.
ControlRemoved When the control is removed from the
Control.ControlCollection, a ControlRemoved
event, occurs.
TabStopChanged It occurs when the property of TabStop is changed
in the Label Control.
BackColorChanged A BackColorChanged event occurs in the Label
control when the value of the BackColor property is
changed.
ControlAdded When a new control is added to the
Control.ControlCollection, a ControlAdded event
occurs.
DragDrop A DragDrop event occurs in the Label control when
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 7
a drag and drop operation is completed.
3. Button Control
Button control is used to perform a click event in Windows Forms, and it can be
clicked by a mouse or by pressing Enter keys. It is used to submit all queries of the
form by clicking the submit button or transfer control to the next form. However, we
can set the buttons on the form by using drag and drop operation.
Button Properties :-
Properties Description
AutoSizeMode It is used to get or set the auto mode value through
which the button can automatically resize in the
Windows form.
BackColor It is used to set the background color of the Button
in the Windows form.
BackgroundImage It is used to set the background image of the button
control.
ForeColor It is used to set or get the foreground color of the
button control.
Image It is used to set or gets the image on the button
control that is displayed.
Location It is used to set the upper-left of the button control's
coordinates relative to the upper-left corner in the
windows form.
Text It is used to set the name of the button control in the
windows form.
AllowDrop It is used to set or get a value representing whether
the button control can accept data that can be
dragged by the user on the form.
TabIndex It is used to set or get the tab order of the button
control within the form.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 8
Button Events :-
BackColorChanged A BackColorChaged event is found in
button control when the Background
property is changed.
BackgroundImageChanged A BackgoundImageChanged event is
found in button control when the value of
the BackgoundImage property is changed.
Click A Click event is found in the button
control when the control is clicked.
ContextManuChanged It is found in button control when the
value of the ContextMenu property is
changed.
ControlAdded A ControlAdded event is found in button
control when a new control is added to the
Control.ControlCollection.
CursorChanged A CursorChanged event is found in button
control when the value of the control is
changed.
DoubleClick When the user makes a double click on
the button, a double click event is found
in the button control.
TextChanged It is found in the button control when the
value of the text property is changed.
DragDrop The DragDrop event is found in the
button control when the drag and drop
operation is completed in the Form.
4. Textbox Control
Text box controls allow entering text on a form at runtime. By default, it takes a
single line of text, however, you can make it accept multiple texts and even add scroll
bars to it.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 9
Let's create a text box by dragging a Text Box control from the Toolbox and dropping
it on the form.
TextBox Properties :-
The following are some of the commonly used properties of the TextBox control –
Sr.No. Property & Description
1 AcceptsReturn
Gets or sets a value indicating whether pressing ENTER in a
multiline TextBox control creates a new line of text in the control
or activates the default button for the form.
2 AutoCompleteCustomSource
Gets or sets a custom
System.Collections.Specialized.StringCollection to use when the
AutoCompleteSourceproperty is set to CustomSource.
3 AutoCompleteMode
Gets or sets an option that controls how automatic completion
works for the TextBox.
4 AutoCompleteSource
Gets or sets a value specifying the source of complete strings used
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 10
for automatic completion.
5 CharacterCasing
Gets or sets whether the TextBox control modifies the case of
characters as they are typed.
6 Font
Gets or sets the font of the text displayed by the control.
7 FontHeight
Gets or sets the height of the font of the control.
8 ForeColor
Gets or sets the foreground color of the control.
9 Lines
Gets or sets the lines of text in a text box control.
10 Multiline
Gets or sets a value indicating whether this is a multiline TextBox
control.
11 PasswordChar
Gets or sets the character used to mask characters of a password in
a single-line TextBox control.
12 ReadOnly
Gets or sets a value indicating whether text in the text box is read-
only.
13 ScrollBars
Gets or sets which scroll bars should appear in a multiline TextBox
control. This property has values −
 None
 Horizontal
 Vertical
 Both
14 TabIndex
Gets or sets the tab order of the control within its container.
15 Text
Gets or sets the current text in the TextBox.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 11
16 TextAlign
Gets or sets how text is aligned in a TextBox control. This property
has values −
 Left
 Right
 Center
17 TextLength
Gets the length of text in the control.
18 WordWrap
Indicates whether a multiline text box control automatically wraps
words to the beginning of the next line when necessary.
TextBox Methods :-
The following are some of the commonly used methods of the TextBox control –
Sr.No. Method Name & Description
1 AppendText
Appends text to the current text of a text box.
2 Clear
Clears all text from the text box control.
3 Copy
Copies the current selection in the text box to the Clipboard.
4 Cut
Moves the current selection in the text box to the Clipboard.
5 Paste
Replaces the current selection in the text box with the contents of
the Clipboard.
6 Paste(String)
Sets the selected text to the specified text without clearing the undo
buffer.
7 ResetText
Resets the Text property to its default value.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 12
8 ToString
Returns a string that represents the TextBoxBase control.
9 Undo
Undoes the last edit operation in the text box.
TextBox Events :-
The following are some of the commonly used events of the Text control −
Sr.No. Event & Description
1 Click
Occurs when the control is clicked.
2 DoubleClick
Occurs when the control is double-clicked.
3 TextAlignChanged
Occurs when the TextAlign property value changes.
Ex:-1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
'Add text to the control
HelloTextBox.Text = "Hello. Welcome to VB.Net Coding!"
End Sub
Password character
Ex-2.
Private Sub PasswordField_TextChanged(sender As Object, e As EventArgs)
Handles PasswordField.TextChanged
PasswordField.PasswordChar = "*"
End Sub
Newline in TextBox
Ex.3-
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 13
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
TextBox1.Multiline = True
TextBox1.Text = "Line 1"
TextBox1.Text = TextBox1.Text & ControlChars.NewLine & "Line 2"
End Sub
Retrieving Integer Values
Ex.4-
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim x As Integer
x = Integer.Parse(age.Text)
MessageBox.Show(x)
End Sub
End Class
ReadOnly TextBox
Ex.5-
Private Sub guru99_TextChanged(sender As Object, e As EventArgs) Handles
Prachi.TextChanged
Tb1.Text = "welcome to VB.Net Notes"
Tb1.ReadOnly = True
End Sub
max length
Ex.6-
Private Sub fullName_TextChanged(sender As Object, e As EventArgs) Handles
fullName.TextChanged
fullName.MaxLength = 8
End Sub
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 14
5. LABEL CONTROL
The Label control represents a standard Windows label. It is generally used to display
some informative text on the GUI which is not changed during runtime.
Let's create a label by dragging a Label control from the Toolbox and dropping it on
the form.
Label Properties :-
The following are some of the commonly used properties of the Label control –
Sr.No. Property & Description
1 Autosize
Gets or sets a value specifying if the control should be
automatically resized to display all its contents.
2 BorderStyle
Gets or sets the border style for the control.
3 FlatStyle
Gets or sets the flat style appearance of the Label control
4 Font
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 15
Gets or sets the font of the text displayed by the control.
5 FontHeight
Gets or sets the height of the font of the control.
6 ForeColor
Gets or sets the foreground color of the control.
7 PreferredHeight
Gets the preferred height of the control.
8 PreferredWidth
Gets the preferred width of the control.
9 TabStop
Gets or sets a value indicating whether the user can tab to the
Label. This property is not used by this class.
10 Text
Gets or sets the text associated with this control.
11 TextAlign
Gets or sets the alignment of text in the label.
Label Methods :-
The following are some of the commonly used methods of the Label control –
Sr.No. Method Name & Description
1 GetPreferredSize
Retrieves the size of a rectangular area into which a control can
be fitted.
2 Refresh
Forces the control to invalidate its client area and immediately
redraw itself and any child controls.
3 Select
Activates the control.
4 Show
Displays the control to the user.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 16
5 ToString
Returns a String that contains the name of the control.
Label Events :-
The following are some of the commonly used events of the Label control –
Sr.No. Event & Description
1 AutoSizeChanged
Occurs when the value of the AutoSize property changes.
2 Click
Occurs when the control is clicked.
3 DoubleClick
Occurs when the control is double-clicked.
4 GotFocus
Occurs when the control receives focus.
5 Leave
Occurs when the input focus leaves the control.
6 LostFocus
Occurs when the control loses focus.
7 TabIndexChanged
Occurs when the TabIndex property value changes.
8 TabStopChanged
Occurs when the TabStop property changes.
9 TextChanged
Occurs when the Text property value changes.
Ex:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) _
Handles MyBase.Load
' Create two buttons to use as the accept and cancel buttons.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 17
' Set window width and height
Me.Height = 300
Me.Width = 560
' Set the caption bar text of the form.
Me.Text = "tutorialspont.com"
' Display a help button on the form.
Me.HelpButton = True
End Sub
Private Sub Label1_Click(sender As Object, e As EventArgs) _
Handles Label1.Click
Label1.Location = New Point(50, 50)
Label1.Text = "You have just moved the label"
End Sub
Private Sub Label1_DoubleClick(sender As Object, e As EventArgs)
Handles Label1.DoubleClick
Dim Label2 As New Label
Label2.Text = "New Label"
Label2.Location = New Point(Label1.Left, Label1.Height + _
Label1.Top + 25)
Me.Controls.Add(Label2)
End Sub
End Class
Microsoft Visual Studio tool bar, it will show the following window −
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 18
Clicking and double clicking the label would produce the following effect −
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 19
6. LISTBOX CONTROL
VB.Net provides several mechanisms for gathering input in a program. A Windows
Forms ListBox control displays a list of choices which the user can select from.
Ex:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ListBox1.Items.Add("Sunday")
ListBox1.Items.Add("Monday")
ListBox1.Items.Add("Tuesday")
ListBox1.Items.Add("Wednesday")
ListBox1.Items.Add("Thursday")
ListBox1.Items.Add("Friday")
ListBox1.Items.Add("Saturday")
ListBox1.SelectionMode = SelectionMode.MultiSimple
End Sub
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 20
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim obj As Object
For Each obj In ListBox1.SelectedItems
MsgBox(obj.ToString)
Next
End Sub
End Class
Listbox Properties:-
S.N Property Description
1 AllowSelection Gets a value indicating whether the
ListBox currently enables selection of
list items.
2 BorderStyle Gets or sets the type of border drawn
around the list box.
3 ColumnWidth Gets of sets the width of columns in a
multicolumn list box.
4 HorizontalExtent Gets or sets the horizontal scrolling
area of a list box.
5 HorizontalScrollBar Gets or sets the value indicating
whether a horizontal scrollbar is
displayed in the list box.
6 ItemHeight Gets or sets the height of an item in
the list box.
7 Items Gets the items of the list box.
8 MultiColumn Gets or sets a value indicating whether
the list box supports multiple columns.
9 ScrollAlwaysVisible Gets or sets a value indicating whether
the vertical scroll bar is shown at all
times.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 21
10 SelectedIndex Gets or sets the zero-based index of
the currently selected item in a list
box.
11 SelectedIndices Gets a collection that contains the
zero-based indexes of all currently
selected items in the list box.
12 SelectedItem Gets or sets the currently selected item
in the list box.
13 SelectedItems Gets a collection containing the
currently selected items in the list box.
14 SelectedValue Gets or sets the value of the member
property specified by the
ValueMember property.
15 SelectionMode Gets or sets the method in which items
are selected in the list box. This
property has values:
 None
 One
 MultiSimple
 MultiExtended
16 Sorted Gets or sets a value indicating whether
the items in the list box are sorted
alphabetically.
17 Text Gets or searches for the text of the
currently selected item in the list box.
18 TopIndex Gets or sets the index of the first
visible item of a list box.
ListBoxMethods :-
The following are some of the commonly used methods of the ListBox control:
S.N Method Name & Description
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 22
1 BeginUpdate
Prevents the control from drawing until the EndUpdate method is
called, while items are added to the ListBox one at a time.
2 ClearSelected
Unselects all items in the ListBox.
3 EndUpdate
Resumes drawing of a list box after it was turned off by the
BeginUpdate method.
4 FindString
Finds the first item in the ListBox that starts with the string
specified as an argument.
5 FindStringExact
Finds the first item in the ListBox that exactly matches the
specified string.
6 GetSelected
Returns a value indicating whether the specified item is selected.
7 SetSelected
Selects or clears the selection for the specified item in a ListBox.
8 OnSelectedIndexChanged
Raises the SelectedIndexChanged event.
8 OnSelectedValueChanged
Raises the SelectedValueChanged event.
ListBoxEvents :-
The following are some of the commonly used events of the ListBox control:
S.N Event Description
1 Click Occurs when a list box is selected.
2 SelectedIndexChanged Occurs when the SelectedIndex
property of a list box is changed.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 23
Ex:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Set the caption bar text of the form.
Me.Text = " Prachi Sasankar "
' creating multi-column and multiselect list box
ListBox1.MultiColumn = True
ListBox1.SelectionMode = SelectionMode.MultiExtended
End Sub
'populates the list
Private Sub Button1_Click_1(sender As Object, e As EventArgs) _
Handles Button1.Click
ListBox1.Items.Add("Safety")
ListBox1.Items.Add("Security")
ListBox1.Items.Add("Governance")
ListBox1.Items.Add("Good Music")
ListBox1.Items.Add("Good Movies")
ListBox1.Items.Add("Good Books")
ListBox1.Items.Add("Education")
ListBox1.Items.Add("Roads")
ListBox1.Items.Add("Health")
ListBox1.Items.Add("Food for all")
ListBox1.Items.Add("Shelter for all")
ListBox1.Items.Add("Industrialisation")
ListBox1.Items.Add("Peace")
ListBox1.Items.Add("Liberty")
ListBox1.Items.Add("Freedom of Speech")
End Sub
'sorting the list
Private Sub Button2_Click(sender As Object, e As EventArgs) _
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 24
Handles Button2.Click
ListBox1.Sorted = True
End Sub
'clears the list
Private Sub Button3_Click(sender As Object, e As EventArgs) _
Handles Button3.Click
ListBox1.Items.Clear()
End Sub
'removing the selected item
Private Sub Button4_Click(sender As Object, e As EventArgs) _
Handles Button4.Click
ListBox1.Items.Remove(ListBox1.SelectedItem.ToString)
End Sub
'counting the number of items
Private Sub Button5_Click(sender As Object, e As EventArgs) _
Handles Button5.Click
Label1.Text = ListBox1.Items.Count
End Sub
'displaying the selected item on the third label
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) _
Handles ListBox1.SelectedIndexChanged
Label3.Text = ListBox1.SelectedItem.ToString()
End Sub
End Class
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 25
7. COMBOBOX CONTROL
The ComboBox control is used to display more than one item in a drop-down list. It is
a combination of Listbox and Textbox in which the user can input only one item.
Furthermore, it also allows a user to select an item from a drop-down list.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 26
ComboBoxProperties:-
The following are some of the commonly used properties of the ComboBox control:
S.
N
Property Description
1 AllowSelection Gets a value indicating whether the list enables
selection of list items.
2 AutoCompleteCust
omSource
Gets or sets a custom
System.Collections.Specialized.StringCollecti
on to use when the
AutoCompleteSourceproperty is set to
CustomSource.
3 AutoCompleteMod
e
Gets or sets an option that controls how
automatic completion works for the
ComboBox.
4 AutoCompleteSour
ce
Gets or sets a value specifying the source of
complete strings used for automatic
completion.
5 DataBindings Gets the data bindings for the control.
6 DataManager Gets the CurrencyManager associated with this
control.
7 DataSource Gets or sets the data source for this
ComboBox.
8 DropDownHeight Gets or sets the height in pixels of the drop-
down portion of the ComboBox.
9 DropDownStyle Gets or sets a value specifying the style of the
combo box.
10 DropDownWidth Gets or sets the width of the of the drop-down
portion of a combo box.
11 DroppedDown Gets or sets a value indicating whether the
combo box is displaying its drop-down
portion.
12 FlatStyle Gets or sets the appearance of the ComboBox.
13 ItemHeight Gets or sets the height of an item in the combo
box.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 27
14 Items Gets an object representing the collection of
the items contained in this ComboBox.
15 MaxDropDownIte
ms
Gets or sets the maximum number of items to
be displayed in the drop-down part of the
combo box.
16 MaxLength Gets or sets the maximum number of
characters a user can enter in the editable area
of the combo box.
17 SelectedIndex Gets or sets the index specifying the currently
selected item.
18 SelectedItem Gets or sets currently selected item in the
ComboBox.
19 SelectedText Gets or sets the text that is selected in the
editable portion of a ComboBox.
20 SelectedValue Gets or sets the value of the member property
specified by the ValueMember property.
21 SelectionLength Gets or sets the number of characters selected
in the editable portion of the combo box.
22 SelectionStart Gets or sets the starting index of text selected
in the combo box.
23 Sorted Gets or sets a value indicating whether the
items in the combo box are sorted.
24 Text Gets or sets the text associated with this
control.
ComboBoxMethods:-
The following are some of the commonly used methods of the ComboBox control:
S.N Method Name & Description
1 BeginUpdate
Prevents the control from drawing until the EndUpdate method is
called, while items are added to the combo box one at a time.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 28
2 EndUpdate
Resumes drawing of a combo box, after it was turned off by the
BeginUpdate method.
3 FindString
Finds the first item in the combo box that starts with the string
specified as an argument.
4 FindStringExact
Finds the first item in the combo box that exactly matches the
specified string.
5 SelectAll
Selects all the text in the editable area of the combo box.
ComboBoxEvents :-
The following are some of the commonly used events of the ComboBox control:
S.N Event Description
1 DropDown Occurs when the drop-down
portion of a combo box is
displayed.
2 DropDownClosed Occurs when the drop-down
portion of a combo box is no
longer visible.
3 DropDownStyleChanged Occurs when the
DropDownStyle property of the
ComboBox has changed.
4 SelectedIndexChanged Occurs when the SelectedIndex
property of a ComboBox
control has changed.
5 SelectionChangeCommitted Occurs when the selected item
has changed and the change
appears in the combo box.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 29
Ex:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
' Set the caption bar text of the form.
Me.Text = " Prachi Sasankar "
End Sub
'sends the selected items to the list box
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
If ComboBox1.SelectedIndex > -1 Then
Dim sindex As Integer
sindex = ComboBox1.SelectedIndex
Dim sitem As Object
sitem = ComboBox1.SelectedItem
ListBox1.Items.Add(sitem)
End If
End Sub
'populates the list
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
ComboBox1.Items.Clear()
ComboBox1.Items.Add("Safety")
ComboBox1.Items.Add("Security")
ComboBox1.Items.Add("Governance")
ComboBox1.Items.Add("Good Music")
ComboBox1.Items.Add("Good Movies")
ComboBox1.Items.Add("Good Books")
ComboBox1.Items.Add("Education")
ComboBox1.Items.Add("Roads")
ComboBox1.Items.Add("Health")
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 30
ComboBox1.Items.Add("Food for all")
ComboBox1.Items.Add("Shelter for all")
ComboBox1.Items.Add("Industrialisation")
ComboBox1.Items.Add("Peace")
ComboBox1.Items.Add("Liberty")
ComboBox1.Items.Add("Freedom of Speech")
ComboBox1.Text = "Select from..."
End Sub
'sorting the list
Private Sub Button3_Click(sender As Object, e As EventArgs)
ComboBox1.Sorted = True
End Sub
'clears the list
Private Sub Button4_Click(sender As Object, e As EventArgs)
ComboBox1.Items.Clear()
End Sub
'displaying the selected item on the label
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs)
_
Handles ListBox1.SelectedIndexChanged
Label1.Text = ComboBox1.SelectedItem.ToString()
End Sub
End Class
8. CHECKED LISTBOX CONTROL
The CheckedListBox is similar to Listbox except that it displays all items in the list
with a checkbox that allows users to check or uncheck single or multiple items.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 31
CheckedListBox Properties :-
There are following properties of the CheckedListBox control.
Properties Description
AccessibilityObject It obtains a value that determines whether the
AccessibilityObject is assigned to the
CheckedListBox control.
AccessibleName It gets or sets a value that tells if the accessible
client application has used the name of the
checkedlistbox control.
AllowSelection It gets a value that indicates whether the ListBox
allows for the item to be selected from the list.
AllowScollOffset It gets or sets a value representing whether the
CheckedListBox control is scrolled in
ScrollControlIntoView(Control).
BorderStyle It is used to set the type of border around the
CheckedListBox by getting or setting a value.
CheckedItems It is used to store a collection of checked items in
the CheckedListBox.
ScrollAlwaysVisible It is used to set or get a value that indicates if the
vertical scroll bar appears in Windows Forms at
all times.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 32
SelectedItems It is used to get all selected items from
CheckedListBox.
SelectionMode It is used to get or set a value representing the
items' selection mode in the CheckedListBox.
TopIndex It is used to set the first visible item at the top of
the index in the CheckedListBox.
CheckedListBox Methods:-
Methods Description
ClearSelected() It is used to unselect all the selected
items in the CheckedListBox.
CreateAccessibilityInstance() It is used to create new accessibility of
the object in the CheckedListBox
Control.
CreateItemCollection() It is used to create a new instance for the
collected item in the list box.
DestroyHandle() It is used to destroy the handle
associated with CheckedListBox.
Equals(Object) It is used to validate whether the
specified object is equal to the current
object in the CheckedListBox or not.
FindForm() It is used to obtain the form in which
CheckedListBox has control.
GetItemText(Object) It is used to get the text of the specified
item in the CheckedListBox.
GetType() It is used to get the current item type in
the CheckedListBox.
Show() A Show() method is used to display the
CheckedListBox Control to the user.
Sort() A Sort() method is used to sort or
organize all the items available in
CheckedListBox.
EX:
CheqListvb.vb
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 33
Public Class CheqListvb
Private Sub CheqListvb_Load(sender As Object, e As EventArgs) Handles MyBase.
Load
Me.Text = " JavaTpoint.com"
CheckedListBox1.Items.Add("VB.NET")
CheckedListBox1.Items.Add("Java")
CheckedListBox1.Items.Add("Python")
CheckedListBox1.Items.Add("C")
CheckedListBox1.Items.Add("C#")
CheckedListBox1.Items.Add("PHP")
CheckedListBox1.Items.Add("JavaScript")
CheckedListBox1.Items.Add("Ruby Language")
CheckedListBox1.Items.Add("Android")
CheckedListBox1.Items.Add("Perl")
Label1.Text = "Choose one or more programming languages of your choice. "
Button1.Text = "Select"
Button2.Text = "Exit"
End Sub
' To submit the checked items, click on Button1 or Select
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Cli
ck
Dim cheq As New System.Text.StringBuilder
For Each item In CheckedListBox1.CheckedItems
cheq.Append(item)
cheq.Append(" ")
Next
MessageBox.Show(" Your Checked Items are : " & cheq.ToString())
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Cli
ck
End 'terminate the program
End Sub
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 34
Output:
In the above list, we can select more than one item from the CheckedListBox in
Windows Form.
After that, click on the Select button to display the selected item in Windows Form.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 35
9. PICTUREBOX CONTROL:
It represents a Windows picture box control for displaying an image. The
PictureBox control is used for displaying images on the form. The Image property
of the control allows you to set an image both at design time or at run time.
Let's create a picture box by dragging a PictureBox control from the Toolbox and
dropping it on the form
PictureBoxControl Properties:
The following are some of the commonly used properties of the PictureBox control:
S.N Property Description
1 AllowDrop Specifies whether the picture box accepts
data that a user drags on it.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 36
2 ErrorImage Gets or specifies an image to be
displayed when an error occurs during
the image-loading process or if the image
load is cancelled.
3 Image Gets or sets the image that is displayed in
the control.
4 ImageLocation Gets or sets the path or the URL for the
image displayed in the control.
5 InitialImage Gets or sets the image displayed in the
control when the main image is loaded
6 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 - the upper left corner of the
image is placed at upper left part of the
picture box
 StrechImage - allows stretching of
the image
 AutoSize - allows resizing the picture
box to the size of the image
 CenterImage - allows centering the
image in the picture box
 Zoom - allows increasing or
decreasing the image size to maintain the
size ratio.
7 TabIndex Gets or sets the tab index value.
8 TabStop Specifies whether the user will be able to
focus on the picture box by using the
TAB key.
9 Text Gets or sets the text for the picture box.
10 WaitOnLoad Specifies whether or not an image is
loaded synchronously.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 37
PictureBoxControl Methods:
The following are some of the commonly used methods of the PictureBox control:
S.N Method Name & Description
1 CancelAsync
Cancels an asynchronous image load.
2 Load
Displays an image in the picture box
3 LoadAsync
Loads image asynchronously.
4 ToString
Returns the string that represents the current picture box.
PictureBoxControl Events :
The following are some of the commonly used events of the PictureBox control:
S.N Event Description
1 CausesValidationChanged Overrides the
Control.CausesValidationChanged
property.
2 Click Occurs when the control is clicked.
3 Enter Overrides the Control.Enter
property.
4 FontChanged Occurs when the value of the Font
property changes.
5 ForeColorChanged Occurs when the value of the
ForeColor property changes.
6 KeyDown Occurs when a key is pressed when
the control has focus.
7 KeyPress Occurs when a key is pressed when
the control has focus.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 38
8 KeyUp Occurs when a key is released
when the control has focus.
9 Leave Occurs when input focus leaves the
PictureBox.
10 LoadCompleted Occurs when the asynchronous
image-load operation is completed,
been canceled, or raised an
exception.
11 LoadProgressChanged Occurs when the progress of an
asynchronous image-loading
operation has changed.
12 Resize Occurs when the control is resized.
13 RightToLeftChanged Occurs when the value of the
RightToLeft property changes.
14 SizeChanged Occurs when the Size property
value changes.
15 SizeModeChanged Occurs when SizeMode changes.
16 TabIndexChanged Occurs when the value of the
TabIndex property changes.
17 TabStopChanged Occurs when the value of the
TabStop property changes.
18 TextChanged Occurs when the value of the Text
property changes.
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Set the caption bar text of the form.
Me.Text = "Prachi Sasankar"
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
PictureBox1.ClientSize = New Size(300, 300)
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 39
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End Sub
End Class
10. SCROLLBAR :
The ScrollBar controls display vertical and horizontal scroll bars on the form. This is
used for navigating through large amount of information. There are two types of scroll
bar controls: HScrollBar for horizontal scroll bars and VScrollBar for vertical scroll
bars. These are used independently from each other.
Let's click on HScrollBar control and VScrollBar control from the Toolbox and place
them on the form.
ScrollBarControlProperties:
The following are some of the commonly used properties of the ScrollBar control:
S.N Property Description
1 AutoSize Gets or sets a value indicating whether the ScrollBar
is automatically resized to fit its contents.
2 BackColor Gets or sets the background color for the control.
3 ForeColor Gets or sets the foreground color of the scroll bar
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 40
control.
4 ImeMode Gets or sets the Input Method Editor (IME) mode
supported by this control.
5 LargeChange Gets or sets a value to be added to or subtracted from
the Value property when the scroll box is moved a
large distance.
6 Maximum Gets or sets the upper limit of values of the scrollable
range.
7 Minimum Gets or sets the lower limit of values of the scrollable
range.
8 SmallChange Gets or sets the value to be added to or subtracted
from the Value property when the scroll box is moved
a small distance.
9 Value Gets or sets a numeric value that represents the
current position of the scroll box on the scroll bar
control.
ScrollBar Control Methods :
The following are some of the commonly used methods of the ScrollBar control:
S.N Method Name & Description
1 OnClick
Generates the Click event.
2 Select
Activates the control.
ScrollBar Control Events:
The following are some of the commonly used events of the ScrollBar control:
S.N Event Description
1 Click Occurs when the control is clicked.
2 DoubleClick Occurs when the user double-clicks
the control.
Prof.Prachi Sasankar - CONTROLS AND EVENTS
VisualBasic.Net Sem-V BCA/MCA/BE 41
3 Scroll Occurs when the control is moved.
4 ValueChanged Occurs when the Value property
changes, either by handling the
Scroll event or programmatically.
Ex:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) _
Handles MyBase.Load
'create two scroll bars
Dim hs As HScrollBar
Dim vs As VScrollBar
hs = New HScrollBar()
vs = New VScrollBar()
'set properties
hs.Location = New Point(10, 200)
hs.Size = New Size(175, 15)
hs.Value = 50
vs.Location = New Point(200, 30)
vs.Size = New Size(15, 175)
hs.Value = 50
'adding the scroll bars to the form
Me.Controls.Add(hs)
Me.Controls.Add(vs)
' Set the caption bar text of the form.
Me.Text = "Prachi Sasankar"
End Sub
End Class

More Related Content

What's hot (20)

Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Data controls ppt
Data controls pptData controls ppt
Data controls ppt
 
Components of .NET Framework
Components of .NET FrameworkComponents of .NET Framework
Components of .NET Framework
 
html-table
html-tablehtml-table
html-table
 
Js ppt
Js pptJs ppt
Js ppt
 
Java swing
Java swingJava swing
Java swing
 
HTML Text formatting tags
HTML Text formatting tagsHTML Text formatting tags
HTML Text formatting tags
 
HTML: Tables and Forms
HTML: Tables and FormsHTML: Tables and Forms
HTML: Tables and Forms
 
introduction to visual basic PPT.pptx
introduction to visual basic PPT.pptxintroduction to visual basic PPT.pptx
introduction to visual basic PPT.pptx
 
Visual Basic 6.0
Visual Basic 6.0Visual Basic 6.0
Visual Basic 6.0
 
DATABASE CONSTRAINTS
DATABASE CONSTRAINTSDATABASE CONSTRAINTS
DATABASE CONSTRAINTS
 
Timer control
Timer controlTimer control
Timer control
 
Sdi & mdi
Sdi & mdiSdi & mdi
Sdi & mdi
 
Cascading Style Sheet (CSS)
Cascading Style Sheet (CSS)Cascading Style Sheet (CSS)
Cascading Style Sheet (CSS)
 
What is CSS?
What is CSS?What is CSS?
What is CSS?
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
Textbox n label
Textbox n labelTextbox n label
Textbox n label
 
C# Access modifiers
C# Access modifiersC# Access modifiers
C# Access modifiers
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 

Similar to VB.Net-Controls and 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
 
Session 1. Bai 1 ve winform
Session 1. Bai 1 ve winformSession 1. Bai 1 ve winform
Session 1. Bai 1 ve winformmrtom16071980
 
06 win forms
06 win forms06 win forms
06 win formsmrjw
 
CheckBox In C#.pptx
CheckBox In C#.pptxCheckBox In C#.pptx
CheckBox In C#.pptxSlemanIsmail
 
Technology and Livelihood Education IV
Technology and Livelihood Education IVTechnology and Livelihood Education IV
Technology and Livelihood Education IVKenneth Osabal
 
VB PPT by ADI PART4.pdf
VB PPT by ADI PART4.pdfVB PPT by ADI PART4.pdf
VB PPT by ADI PART4.pdfAdiseshaK
 
engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptsharanyak0721
 
Grasping The LightSwitch Paradigm
Grasping The LightSwitch ParadigmGrasping The LightSwitch Paradigm
Grasping The LightSwitch ParadigmAndrew Brust
 
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 Javasuraj pandey
 
3.5 the controls object
3.5   the controls object3.5   the controls object
3.5 the controls objectallenbailey
 
Chapter 1
Chapter 1Chapter 1
Chapter 1gebrsh
 

Similar to VB.Net-Controls and events (20)

Controls events
Controls eventsControls events
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.15
 
Unit2
Unit2Unit2
Unit2
 
Session 1. Bai 1 ve winform
Session 1. Bai 1 ve winformSession 1. Bai 1 ve winform
Session 1. Bai 1 ve winform
 
06 win forms
06 win forms06 win forms
06 win forms
 
CheckBox In C#.pptx
CheckBox In C#.pptxCheckBox In C#.pptx
CheckBox In C#.pptx
 
Chapter 02
Chapter 02Chapter 02
Chapter 02
 
WPF Controls
WPF ControlsWPF Controls
WPF Controls
 
Technology and Livelihood Education IV
Technology and Livelihood Education IVTechnology and Livelihood Education IV
Technology and Livelihood Education IV
 
VB PPT by ADI PART4.pdf
VB PPT by ADI PART4.pdfVB PPT by ADI PART4.pdf
VB PPT by ADI PART4.pdf
 
VB PPT by ADI PART4.pdf
VB PPT by ADI PART4.pdfVB PPT by ADI PART4.pdf
VB PPT by ADI PART4.pdf
 
engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.ppt
 
Grasping The LightSwitch Paradigm
Grasping The LightSwitch ParadigmGrasping The LightSwitch Paradigm
Grasping The LightSwitch Paradigm
 
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
 
Vb6.0 intro
Vb6.0 introVb6.0 intro
Vb6.0 intro
 
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
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Chapter 14
Chapter 14Chapter 14
Chapter 14
 
Mca 504 dotnet_unit5
Mca 504 dotnet_unit5Mca 504 dotnet_unit5
Mca 504 dotnet_unit5
 

More from Prachi Sasankar

St all about test case-p3
St all about test case-p3St all about test case-p3
St all about test case-p3Prachi Sasankar
 
Importance of E- commerce
Importance of E- commerceImportance of E- commerce
Importance of E- commercePrachi Sasankar
 
Wireless application protocol
Wireless application protocolWireless application protocol
Wireless application protocolPrachi Sasankar
 
Ecomm-History and Overview
Ecomm-History and OverviewEcomm-History and Overview
Ecomm-History and OverviewPrachi Sasankar
 
Unix shell programming intro-part-1
Unix shell programming intro-part-1Unix shell programming intro-part-1
Unix shell programming intro-part-1Prachi Sasankar
 
Ide and datatypes vb-net-u-ii-p2
Ide and datatypes  vb-net-u-ii-p2Ide and datatypes  vb-net-u-ii-p2
Ide and datatypes vb-net-u-ii-p2Prachi Sasankar
 
ST-All about Test Case-p3
ST-All about Test Case-p3ST-All about Test Case-p3
ST-All about Test Case-p3Prachi Sasankar
 
Types of software testing
Types of software testingTypes of software testing
Types of software testingPrachi Sasankar
 
I ntroduction to software testing part1
I ntroduction to software testing part1I ntroduction to software testing part1
I ntroduction to software testing part1Prachi Sasankar
 
Ty bca-sem-v-introduction to vb.net-i-uploaded
Ty bca-sem-v-introduction to vb.net-i-uploadedTy bca-sem-v-introduction to vb.net-i-uploaded
Ty bca-sem-v-introduction to vb.net-i-uploadedPrachi Sasankar
 
Software Engineering Overview
Software Engineering OverviewSoftware Engineering Overview
Software Engineering OverviewPrachi Sasankar
 

More from Prachi Sasankar (13)

Software metrics
Software metricsSoftware metrics
Software metrics
 
St all about test case-p3
St all about test case-p3St all about test case-p3
St all about test case-p3
 
Importance of E- commerce
Importance of E- commerceImportance of E- commerce
Importance of E- commerce
 
Wireless application protocol
Wireless application protocolWireless application protocol
Wireless application protocol
 
Ecomm-History and Overview
Ecomm-History and OverviewEcomm-History and Overview
Ecomm-History and Overview
 
E-Comm-overview
E-Comm-overviewE-Comm-overview
E-Comm-overview
 
Unix shell programming intro-part-1
Unix shell programming intro-part-1Unix shell programming intro-part-1
Unix shell programming intro-part-1
 
Ide and datatypes vb-net-u-ii-p2
Ide and datatypes  vb-net-u-ii-p2Ide and datatypes  vb-net-u-ii-p2
Ide and datatypes vb-net-u-ii-p2
 
ST-All about Test Case-p3
ST-All about Test Case-p3ST-All about Test Case-p3
ST-All about Test Case-p3
 
Types of software testing
Types of software testingTypes of software testing
Types of software testing
 
I ntroduction to software testing part1
I ntroduction to software testing part1I ntroduction to software testing part1
I ntroduction to software testing part1
 
Ty bca-sem-v-introduction to vb.net-i-uploaded
Ty bca-sem-v-introduction to vb.net-i-uploadedTy bca-sem-v-introduction to vb.net-i-uploaded
Ty bca-sem-v-introduction to vb.net-i-uploaded
 
Software Engineering Overview
Software Engineering OverviewSoftware Engineering Overview
Software Engineering Overview
 

Recently uploaded

Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 

VB.Net-Controls and events

  • 1. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 1 CONTROLS: An object is a type of user interface element you create on a Visual Basic form by using a toolbox control. In fact, in Visual Basic, the form itself is an object. Every Visual Basic control consists of three important elements −  Properties which describe the object,  Methods cause an object to do something and  Events are what happened when an object does something. Control Properties All the Visual Basic Objects can be moved, resized or customized by setting their properties. A property is a value or characteristic held by a Visual Basic object, such as Caption or Fore Color. Properties can be set at design time by using the Properties window or at run time by using statements in the program code. Ex: Object.Property = Value Where  Object is the name of the object you're customizing.  Property is the characteristic you want to change.  Value is the new property setting. Control Methods A method is a procedure created as a member of a class and they cause an object to do something. Methods are used to access or manipulate the characteristics of an object or a variable. There are mainly two categories of methods you will use in your classes −  If you are using a control such as one of those provided by the Toolbox, you can call any of its public methods. The requirements of such a method depend on the class being used.  If none of the existing methods can perform your desired task, you can add a method to a class.
  • 2. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 2 Ex: Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MessageBox.Show("Hello, World") End Sub End Class Control Events An event is a signal that informs an application that something important has occurred. For example, when a user clicks a control on a form, the form can raise a Click event and call a procedure that handles the event. There are various types of events associated with a Form like click, double click, close, load, resize, etc. Following is the default structure of a form Load event handler subroutine. Ex: Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'event handler code goes here End Sub 1. Form Controls A Form is used in VB.NET to create a form-based or window-based application. Using the form, we can build a attractive user interface. It is like a container for holding different control that allows the user to interact with an application. The controls are an object in a form such as buttons, Textboxes, Textarea, labels, etc. to perform some action. However, we can add any control to the runtime by creating an instance of it. Form Properties :- The following are the most important list of properties related to a form. And these properties can be set or read while the application is being executed.
  • 3. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 3 Properties Description BackColor It is used to set the background color for the form. BackgroundImage It is used to set the background image of the form. Cursor It is used to set the cursor image when it hovers over the form. AllowDrop Using the AllowDrop control in a form, it allows whether to drag and drop on the form. Font It is used to get or set the font used in a form. Locked It determines whether the form is locked or not. FormBorderStyle It is used to set or get border style in a form. Text It is used to set the title for a form window. MinimizeBox MinimizeBox It is used to display the minimum option on the title bar of the form. IsMDIChild It is used to authenticate whether a form is a container of a Multiple Document Interface (MDI) child form. Autoscroll It allows whether to enable auto-scrolling in a form. MaximizeBox It is used to display the maximum option on the title bar of the form. MaximumSize It is used to set the maximum height and width of the form. Language It is used to specifies the localized language in a form. AcceptButton It is used to set the form button if the enter key is pressed. Top, Left It is used to set the top-left corner coordinates of the form in pixel. Name It is used to define the name of the form. MinimumSize It is used to set the minimum height and width of the form. Enabled It uses the True or False value to enable mouse or keyboard events in the form. TopMost It uses a Boolean value that represents whether you want to put the window form on top of the other form. By default, it is False.
  • 4. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 4 Form Events :- The following are the most important list of events related to a form. Events Description Activated An activated event is found when the user or program activates the form. Click A click event is active when the form is clicked. Closed A closed event is found before closing the form. Closing It exists when a form is closing. DoubleClick DoubleClick The DoubleClick event is activated when a user double clicks on the form. DragDrop A DragDrop event is activated when a drag and drop operation is performed. MouseDown A MouseDown event is activated when the mouse pointer is on the form, and the mouse button is pressed. GotFocus A GotFocus event is activated when the form control receives a focus. HelpButtonClicked It is activated when a user clicked on the help button. KeyDown A KeyDown event is activated when a key is pressed while focussing on the form. KeyUp A KeyUp event is activated when a key is released while focusing on the form. Load The load event is used to load a form before it is first displayed. LostFocus It is activated when the form loses focus. MouseEnter A MouseEnter event is activated when the mouse pointer enters the form. MouseHover A MouseHover event is activated when the mouse pointer put on the form. MouseLeave A MouseLeave event is activated when the mouse
  • 5. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 5 pointer leaves the form surface. Shown It is activated whenever the form is displayed for the first time. Scroll A Scroll event is activated when a form is scrolled through a user or code. Resize A Resize event is activated when a form is resized. Move A Move event is activated when a form is moved. 2. Label Control In VB.NET, a label control is used to display descriptive text for the form in control. It does not participate in user input or keyboard or mouse events. Also, we cannot rename labels at runtime. The labels are defined in the class System.Windows.Forms namespace. Label Properties :- Properties Description AutoSize As the name defines, an AutoSize property of label control is used to set or get a value if it is automatically resized to display all its contents. Border Style It is used to set the style of the border in the Windows form. PreferredWidth It is used to set or get the preferred width for the Label control. Font It is used to get or set the font of the text displayed on a Windows form. PreferredHeight It is used to set the height for the Label Control. TextAlign It is used to set the alignment of text such as centre, bottom, top, left, or right. ForeColor It is used to set the color of the text. Text It is used to set the name of a label in the Windows Form. ContextMenu It is used to get or sets the shortcut menu associated
  • 6. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 6 with the Label control. DefaultSize It is used to get the default size of the Label control. Image It is used to set the image to a label in Windows Form. ImageIndex It is used to set the index value to a label control displayed on the Windows form. Label Events:- Events Description AutoSizeChanged An AutoSizeChanged event occurs in the Label control when the value of AutoSize property is changed. Click Click event is occurring in the Label Control to perform a click. DoubleClick When a user performs a double-clicked in the Label control, the DoubleClick event occurs. GotFocus It occurs when the Label Control receives focus on the Window Form. Leave The Leave event is found when the input focus leaves the Label Control. TabIndexChanged It occurs when the value of Tabindex property is changed in the Label control. ControlRemoved When the control is removed from the Control.ControlCollection, a ControlRemoved event, occurs. TabStopChanged It occurs when the property of TabStop is changed in the Label Control. BackColorChanged A BackColorChanged event occurs in the Label control when the value of the BackColor property is changed. ControlAdded When a new control is added to the Control.ControlCollection, a ControlAdded event occurs. DragDrop A DragDrop event occurs in the Label control when
  • 7. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 7 a drag and drop operation is completed. 3. Button Control Button control is used to perform a click event in Windows Forms, and it can be clicked by a mouse or by pressing Enter keys. It is used to submit all queries of the form by clicking the submit button or transfer control to the next form. However, we can set the buttons on the form by using drag and drop operation. Button Properties :- Properties Description AutoSizeMode It is used to get or set the auto mode value through which the button can automatically resize in the Windows form. BackColor It is used to set the background color of the Button in the Windows form. BackgroundImage It is used to set the background image of the button control. ForeColor It is used to set or get the foreground color of the button control. Image It is used to set or gets the image on the button control that is displayed. Location It is used to set the upper-left of the button control's coordinates relative to the upper-left corner in the windows form. Text It is used to set the name of the button control in the windows form. AllowDrop It is used to set or get a value representing whether the button control can accept data that can be dragged by the user on the form. TabIndex It is used to set or get the tab order of the button control within the form.
  • 8. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 8 Button Events :- BackColorChanged A BackColorChaged event is found in button control when the Background property is changed. BackgroundImageChanged A BackgoundImageChanged event is found in button control when the value of the BackgoundImage property is changed. Click A Click event is found in the button control when the control is clicked. ContextManuChanged It is found in button control when the value of the ContextMenu property is changed. ControlAdded A ControlAdded event is found in button control when a new control is added to the Control.ControlCollection. CursorChanged A CursorChanged event is found in button control when the value of the control is changed. DoubleClick When the user makes a double click on the button, a double click event is found in the button control. TextChanged It is found in the button control when the value of the text property is changed. DragDrop The DragDrop event is found in the button control when the drag and drop operation is completed in the Form. 4. Textbox Control Text box controls allow entering text on a form at runtime. By default, it takes a single line of text, however, you can make it accept multiple texts and even add scroll bars to it.
  • 9. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 9 Let's create a text box by dragging a Text Box control from the Toolbox and dropping it on the form. TextBox Properties :- The following are some of the commonly used properties of the TextBox control – Sr.No. Property & Description 1 AcceptsReturn Gets or sets a value indicating whether pressing ENTER in a multiline TextBox control creates a new line of text in the control or activates the default button for the form. 2 AutoCompleteCustomSource Gets or sets a custom System.Collections.Specialized.StringCollection to use when the AutoCompleteSourceproperty is set to CustomSource. 3 AutoCompleteMode Gets or sets an option that controls how automatic completion works for the TextBox. 4 AutoCompleteSource Gets or sets a value specifying the source of complete strings used
  • 10. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 10 for automatic completion. 5 CharacterCasing Gets or sets whether the TextBox control modifies the case of characters as they are typed. 6 Font Gets or sets the font of the text displayed by the control. 7 FontHeight Gets or sets the height of the font of the control. 8 ForeColor Gets or sets the foreground color of the control. 9 Lines Gets or sets the lines of text in a text box control. 10 Multiline Gets or sets a value indicating whether this is a multiline TextBox control. 11 PasswordChar Gets or sets the character used to mask characters of a password in a single-line TextBox control. 12 ReadOnly Gets or sets a value indicating whether text in the text box is read- only. 13 ScrollBars Gets or sets which scroll bars should appear in a multiline TextBox control. This property has values −  None  Horizontal  Vertical  Both 14 TabIndex Gets or sets the tab order of the control within its container. 15 Text Gets or sets the current text in the TextBox.
  • 11. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 11 16 TextAlign Gets or sets how text is aligned in a TextBox control. This property has values −  Left  Right  Center 17 TextLength Gets the length of text in the control. 18 WordWrap Indicates whether a multiline text box control automatically wraps words to the beginning of the next line when necessary. TextBox Methods :- The following are some of the commonly used methods of the TextBox control – Sr.No. Method Name & Description 1 AppendText Appends text to the current text of a text box. 2 Clear Clears all text from the text box control. 3 Copy Copies the current selection in the text box to the Clipboard. 4 Cut Moves the current selection in the text box to the Clipboard. 5 Paste Replaces the current selection in the text box with the contents of the Clipboard. 6 Paste(String) Sets the selected text to the specified text without clearing the undo buffer. 7 ResetText Resets the Text property to its default value.
  • 12. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 12 8 ToString Returns a string that represents the TextBoxBase control. 9 Undo Undoes the last edit operation in the text box. TextBox Events :- The following are some of the commonly used events of the Text control − Sr.No. Event & Description 1 Click Occurs when the control is clicked. 2 DoubleClick Occurs when the control is double-clicked. 3 TextAlignChanged Occurs when the TextAlign property value changes. Ex:-1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'Add text to the control HelloTextBox.Text = "Hello. Welcome to VB.Net Coding!" End Sub Password character Ex-2. Private Sub PasswordField_TextChanged(sender As Object, e As EventArgs) Handles PasswordField.TextChanged PasswordField.PasswordChar = "*" End Sub Newline in TextBox Ex.3-
  • 13. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 13 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load TextBox1.Multiline = True TextBox1.Text = "Line 1" TextBox1.Text = TextBox1.Text & ControlChars.NewLine & "Line 2" End Sub Retrieving Integer Values Ex.4- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim x As Integer x = Integer.Parse(age.Text) MessageBox.Show(x) End Sub End Class ReadOnly TextBox Ex.5- Private Sub guru99_TextChanged(sender As Object, e As EventArgs) Handles Prachi.TextChanged Tb1.Text = "welcome to VB.Net Notes" Tb1.ReadOnly = True End Sub max length Ex.6- Private Sub fullName_TextChanged(sender As Object, e As EventArgs) Handles fullName.TextChanged fullName.MaxLength = 8 End Sub
  • 14. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 14 5. LABEL CONTROL The Label control represents a standard Windows label. It is generally used to display some informative text on the GUI which is not changed during runtime. Let's create a label by dragging a Label control from the Toolbox and dropping it on the form. Label Properties :- The following are some of the commonly used properties of the Label control – Sr.No. Property & Description 1 Autosize Gets or sets a value specifying if the control should be automatically resized to display all its contents. 2 BorderStyle Gets or sets the border style for the control. 3 FlatStyle Gets or sets the flat style appearance of the Label control 4 Font
  • 15. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 15 Gets or sets the font of the text displayed by the control. 5 FontHeight Gets or sets the height of the font of the control. 6 ForeColor Gets or sets the foreground color of the control. 7 PreferredHeight Gets the preferred height of the control. 8 PreferredWidth Gets the preferred width of the control. 9 TabStop Gets or sets a value indicating whether the user can tab to the Label. This property is not used by this class. 10 Text Gets or sets the text associated with this control. 11 TextAlign Gets or sets the alignment of text in the label. Label Methods :- The following are some of the commonly used methods of the Label control – Sr.No. Method Name & Description 1 GetPreferredSize Retrieves the size of a rectangular area into which a control can be fitted. 2 Refresh Forces the control to invalidate its client area and immediately redraw itself and any child controls. 3 Select Activates the control. 4 Show Displays the control to the user.
  • 16. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 16 5 ToString Returns a String that contains the name of the control. Label Events :- The following are some of the commonly used events of the Label control – Sr.No. Event & Description 1 AutoSizeChanged Occurs when the value of the AutoSize property changes. 2 Click Occurs when the control is clicked. 3 DoubleClick Occurs when the control is double-clicked. 4 GotFocus Occurs when the control receives focus. 5 Leave Occurs when the input focus leaves the control. 6 LostFocus Occurs when the control loses focus. 7 TabIndexChanged Occurs when the TabIndex property value changes. 8 TabStopChanged Occurs when the TabStop property changes. 9 TextChanged Occurs when the Text property value changes. Ex: Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) _ Handles MyBase.Load ' Create two buttons to use as the accept and cancel buttons.
  • 17. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 17 ' Set window width and height Me.Height = 300 Me.Width = 560 ' Set the caption bar text of the form. Me.Text = "tutorialspont.com" ' Display a help button on the form. Me.HelpButton = True End Sub Private Sub Label1_Click(sender As Object, e As EventArgs) _ Handles Label1.Click Label1.Location = New Point(50, 50) Label1.Text = "You have just moved the label" End Sub Private Sub Label1_DoubleClick(sender As Object, e As EventArgs) Handles Label1.DoubleClick Dim Label2 As New Label Label2.Text = "New Label" Label2.Location = New Point(Label1.Left, Label1.Height + _ Label1.Top + 25) Me.Controls.Add(Label2) End Sub End Class Microsoft Visual Studio tool bar, it will show the following window −
  • 18. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 18 Clicking and double clicking the label would produce the following effect −
  • 19. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 19 6. LISTBOX CONTROL VB.Net provides several mechanisms for gathering input in a program. A Windows Forms ListBox control displays a list of choices which the user can select from. Ex: Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ListBox1.Items.Add("Sunday") ListBox1.Items.Add("Monday") ListBox1.Items.Add("Tuesday") ListBox1.Items.Add("Wednesday") ListBox1.Items.Add("Thursday") ListBox1.Items.Add("Friday") ListBox1.Items.Add("Saturday") ListBox1.SelectionMode = SelectionMode.MultiSimple End Sub
  • 20. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 20 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim obj As Object For Each obj In ListBox1.SelectedItems MsgBox(obj.ToString) Next End Sub End Class Listbox Properties:- S.N Property Description 1 AllowSelection Gets a value indicating whether the ListBox currently enables selection of list items. 2 BorderStyle Gets or sets the type of border drawn around the list box. 3 ColumnWidth Gets of sets the width of columns in a multicolumn list box. 4 HorizontalExtent Gets or sets the horizontal scrolling area of a list box. 5 HorizontalScrollBar Gets or sets the value indicating whether a horizontal scrollbar is displayed in the list box. 6 ItemHeight Gets or sets the height of an item in the list box. 7 Items Gets the items of the list box. 8 MultiColumn Gets or sets a value indicating whether the list box supports multiple columns. 9 ScrollAlwaysVisible Gets or sets a value indicating whether the vertical scroll bar is shown at all times.
  • 21. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 21 10 SelectedIndex Gets or sets the zero-based index of the currently selected item in a list box. 11 SelectedIndices Gets a collection that contains the zero-based indexes of all currently selected items in the list box. 12 SelectedItem Gets or sets the currently selected item in the list box. 13 SelectedItems Gets a collection containing the currently selected items in the list box. 14 SelectedValue Gets or sets the value of the member property specified by the ValueMember property. 15 SelectionMode Gets or sets the method in which items are selected in the list box. This property has values:  None  One  MultiSimple  MultiExtended 16 Sorted Gets or sets a value indicating whether the items in the list box are sorted alphabetically. 17 Text Gets or searches for the text of the currently selected item in the list box. 18 TopIndex Gets or sets the index of the first visible item of a list box. ListBoxMethods :- The following are some of the commonly used methods of the ListBox control: S.N Method Name & Description
  • 22. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 22 1 BeginUpdate Prevents the control from drawing until the EndUpdate method is called, while items are added to the ListBox one at a time. 2 ClearSelected Unselects all items in the ListBox. 3 EndUpdate Resumes drawing of a list box after it was turned off by the BeginUpdate method. 4 FindString Finds the first item in the ListBox that starts with the string specified as an argument. 5 FindStringExact Finds the first item in the ListBox that exactly matches the specified string. 6 GetSelected Returns a value indicating whether the specified item is selected. 7 SetSelected Selects or clears the selection for the specified item in a ListBox. 8 OnSelectedIndexChanged Raises the SelectedIndexChanged event. 8 OnSelectedValueChanged Raises the SelectedValueChanged event. ListBoxEvents :- The following are some of the commonly used events of the ListBox control: S.N Event Description 1 Click Occurs when a list box is selected. 2 SelectedIndexChanged Occurs when the SelectedIndex property of a list box is changed.
  • 23. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 23 Ex: Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ' Set the caption bar text of the form. Me.Text = " Prachi Sasankar " ' creating multi-column and multiselect list box ListBox1.MultiColumn = True ListBox1.SelectionMode = SelectionMode.MultiExtended End Sub 'populates the list Private Sub Button1_Click_1(sender As Object, e As EventArgs) _ Handles Button1.Click ListBox1.Items.Add("Safety") ListBox1.Items.Add("Security") ListBox1.Items.Add("Governance") ListBox1.Items.Add("Good Music") ListBox1.Items.Add("Good Movies") ListBox1.Items.Add("Good Books") ListBox1.Items.Add("Education") ListBox1.Items.Add("Roads") ListBox1.Items.Add("Health") ListBox1.Items.Add("Food for all") ListBox1.Items.Add("Shelter for all") ListBox1.Items.Add("Industrialisation") ListBox1.Items.Add("Peace") ListBox1.Items.Add("Liberty") ListBox1.Items.Add("Freedom of Speech") End Sub 'sorting the list Private Sub Button2_Click(sender As Object, e As EventArgs) _
  • 24. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 24 Handles Button2.Click ListBox1.Sorted = True End Sub 'clears the list Private Sub Button3_Click(sender As Object, e As EventArgs) _ Handles Button3.Click ListBox1.Items.Clear() End Sub 'removing the selected item Private Sub Button4_Click(sender As Object, e As EventArgs) _ Handles Button4.Click ListBox1.Items.Remove(ListBox1.SelectedItem.ToString) End Sub 'counting the number of items Private Sub Button5_Click(sender As Object, e As EventArgs) _ Handles Button5.Click Label1.Text = ListBox1.Items.Count End Sub 'displaying the selected item on the third label Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) _ Handles ListBox1.SelectedIndexChanged Label3.Text = ListBox1.SelectedItem.ToString() End Sub End Class
  • 25. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 25 7. COMBOBOX CONTROL The ComboBox control is used to display more than one item in a drop-down list. It is a combination of Listbox and Textbox in which the user can input only one item. Furthermore, it also allows a user to select an item from a drop-down list.
  • 26. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 26 ComboBoxProperties:- The following are some of the commonly used properties of the ComboBox control: S. N Property Description 1 AllowSelection Gets a value indicating whether the list enables selection of list items. 2 AutoCompleteCust omSource Gets or sets a custom System.Collections.Specialized.StringCollecti on to use when the AutoCompleteSourceproperty is set to CustomSource. 3 AutoCompleteMod e Gets or sets an option that controls how automatic completion works for the ComboBox. 4 AutoCompleteSour ce Gets or sets a value specifying the source of complete strings used for automatic completion. 5 DataBindings Gets the data bindings for the control. 6 DataManager Gets the CurrencyManager associated with this control. 7 DataSource Gets or sets the data source for this ComboBox. 8 DropDownHeight Gets or sets the height in pixels of the drop- down portion of the ComboBox. 9 DropDownStyle Gets or sets a value specifying the style of the combo box. 10 DropDownWidth Gets or sets the width of the of the drop-down portion of a combo box. 11 DroppedDown Gets or sets a value indicating whether the combo box is displaying its drop-down portion. 12 FlatStyle Gets or sets the appearance of the ComboBox. 13 ItemHeight Gets or sets the height of an item in the combo box.
  • 27. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 27 14 Items Gets an object representing the collection of the items contained in this ComboBox. 15 MaxDropDownIte ms Gets or sets the maximum number of items to be displayed in the drop-down part of the combo box. 16 MaxLength Gets or sets the maximum number of characters a user can enter in the editable area of the combo box. 17 SelectedIndex Gets or sets the index specifying the currently selected item. 18 SelectedItem Gets or sets currently selected item in the ComboBox. 19 SelectedText Gets or sets the text that is selected in the editable portion of a ComboBox. 20 SelectedValue Gets or sets the value of the member property specified by the ValueMember property. 21 SelectionLength Gets or sets the number of characters selected in the editable portion of the combo box. 22 SelectionStart Gets or sets the starting index of text selected in the combo box. 23 Sorted Gets or sets a value indicating whether the items in the combo box are sorted. 24 Text Gets or sets the text associated with this control. ComboBoxMethods:- The following are some of the commonly used methods of the ComboBox control: S.N Method Name & Description 1 BeginUpdate Prevents the control from drawing until the EndUpdate method is called, while items are added to the combo box one at a time.
  • 28. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 28 2 EndUpdate Resumes drawing of a combo box, after it was turned off by the BeginUpdate method. 3 FindString Finds the first item in the combo box that starts with the string specified as an argument. 4 FindStringExact Finds the first item in the combo box that exactly matches the specified string. 5 SelectAll Selects all the text in the editable area of the combo box. ComboBoxEvents :- The following are some of the commonly used events of the ComboBox control: S.N Event Description 1 DropDown Occurs when the drop-down portion of a combo box is displayed. 2 DropDownClosed Occurs when the drop-down portion of a combo box is no longer visible. 3 DropDownStyleChanged Occurs when the DropDownStyle property of the ComboBox has changed. 4 SelectedIndexChanged Occurs when the SelectedIndex property of a ComboBox control has changed. 5 SelectionChangeCommitted Occurs when the selected item has changed and the change appears in the combo box.
  • 29. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 29 Ex: Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ' Set the caption bar text of the form. Me.Text = " Prachi Sasankar " End Sub 'sends the selected items to the list box Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If ComboBox1.SelectedIndex > -1 Then Dim sindex As Integer sindex = ComboBox1.SelectedIndex Dim sitem As Object sitem = ComboBox1.SelectedItem ListBox1.Items.Add(sitem) End If End Sub 'populates the list Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click ComboBox1.Items.Clear() ComboBox1.Items.Add("Safety") ComboBox1.Items.Add("Security") ComboBox1.Items.Add("Governance") ComboBox1.Items.Add("Good Music") ComboBox1.Items.Add("Good Movies") ComboBox1.Items.Add("Good Books") ComboBox1.Items.Add("Education") ComboBox1.Items.Add("Roads") ComboBox1.Items.Add("Health")
  • 30. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 30 ComboBox1.Items.Add("Food for all") ComboBox1.Items.Add("Shelter for all") ComboBox1.Items.Add("Industrialisation") ComboBox1.Items.Add("Peace") ComboBox1.Items.Add("Liberty") ComboBox1.Items.Add("Freedom of Speech") ComboBox1.Text = "Select from..." End Sub 'sorting the list Private Sub Button3_Click(sender As Object, e As EventArgs) ComboBox1.Sorted = True End Sub 'clears the list Private Sub Button4_Click(sender As Object, e As EventArgs) ComboBox1.Items.Clear() End Sub 'displaying the selected item on the label Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) _ Handles ListBox1.SelectedIndexChanged Label1.Text = ComboBox1.SelectedItem.ToString() End Sub End Class 8. CHECKED LISTBOX CONTROL The CheckedListBox is similar to Listbox except that it displays all items in the list with a checkbox that allows users to check or uncheck single or multiple items.
  • 31. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 31 CheckedListBox Properties :- There are following properties of the CheckedListBox control. Properties Description AccessibilityObject It obtains a value that determines whether the AccessibilityObject is assigned to the CheckedListBox control. AccessibleName It gets or sets a value that tells if the accessible client application has used the name of the checkedlistbox control. AllowSelection It gets a value that indicates whether the ListBox allows for the item to be selected from the list. AllowScollOffset It gets or sets a value representing whether the CheckedListBox control is scrolled in ScrollControlIntoView(Control). BorderStyle It is used to set the type of border around the CheckedListBox by getting or setting a value. CheckedItems It is used to store a collection of checked items in the CheckedListBox. ScrollAlwaysVisible It is used to set or get a value that indicates if the vertical scroll bar appears in Windows Forms at all times.
  • 32. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 32 SelectedItems It is used to get all selected items from CheckedListBox. SelectionMode It is used to get or set a value representing the items' selection mode in the CheckedListBox. TopIndex It is used to set the first visible item at the top of the index in the CheckedListBox. CheckedListBox Methods:- Methods Description ClearSelected() It is used to unselect all the selected items in the CheckedListBox. CreateAccessibilityInstance() It is used to create new accessibility of the object in the CheckedListBox Control. CreateItemCollection() It is used to create a new instance for the collected item in the list box. DestroyHandle() It is used to destroy the handle associated with CheckedListBox. Equals(Object) It is used to validate whether the specified object is equal to the current object in the CheckedListBox or not. FindForm() It is used to obtain the form in which CheckedListBox has control. GetItemText(Object) It is used to get the text of the specified item in the CheckedListBox. GetType() It is used to get the current item type in the CheckedListBox. Show() A Show() method is used to display the CheckedListBox Control to the user. Sort() A Sort() method is used to sort or organize all the items available in CheckedListBox. EX: CheqListvb.vb
  • 33. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 33 Public Class CheqListvb Private Sub CheqListvb_Load(sender As Object, e As EventArgs) Handles MyBase. Load Me.Text = " JavaTpoint.com" CheckedListBox1.Items.Add("VB.NET") CheckedListBox1.Items.Add("Java") CheckedListBox1.Items.Add("Python") CheckedListBox1.Items.Add("C") CheckedListBox1.Items.Add("C#") CheckedListBox1.Items.Add("PHP") CheckedListBox1.Items.Add("JavaScript") CheckedListBox1.Items.Add("Ruby Language") CheckedListBox1.Items.Add("Android") CheckedListBox1.Items.Add("Perl") Label1.Text = "Choose one or more programming languages of your choice. " Button1.Text = "Select" Button2.Text = "Exit" End Sub ' To submit the checked items, click on Button1 or Select Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Cli ck Dim cheq As New System.Text.StringBuilder For Each item In CheckedListBox1.CheckedItems cheq.Append(item) cheq.Append(" ") Next MessageBox.Show(" Your Checked Items are : " & cheq.ToString()) End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Cli ck End 'terminate the program End Sub
  • 34. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 34 Output: In the above list, we can select more than one item from the CheckedListBox in Windows Form. After that, click on the Select button to display the selected item in Windows Form.
  • 35. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 35 9. PICTUREBOX CONTROL: It represents a Windows picture box control for displaying an image. The PictureBox control is used for displaying images on the form. The Image property of the control allows you to set an image both at design time or at run time. Let's create a picture box by dragging a PictureBox control from the Toolbox and dropping it on the form PictureBoxControl Properties: The following are some of the commonly used properties of the PictureBox control: S.N Property Description 1 AllowDrop Specifies whether the picture box accepts data that a user drags on it.
  • 36. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 36 2 ErrorImage Gets or specifies an image to be displayed when an error occurs during the image-loading process or if the image load is cancelled. 3 Image Gets or sets the image that is displayed in the control. 4 ImageLocation Gets or sets the path or the URL for the image displayed in the control. 5 InitialImage Gets or sets the image displayed in the control when the main image is loaded 6 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 - the upper left corner of the image is placed at upper left part of the picture box  StrechImage - allows stretching of the image  AutoSize - allows resizing the picture box to the size of the image  CenterImage - allows centering the image in the picture box  Zoom - allows increasing or decreasing the image size to maintain the size ratio. 7 TabIndex Gets or sets the tab index value. 8 TabStop Specifies whether the user will be able to focus on the picture box by using the TAB key. 9 Text Gets or sets the text for the picture box. 10 WaitOnLoad Specifies whether or not an image is loaded synchronously.
  • 37. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 37 PictureBoxControl Methods: The following are some of the commonly used methods of the PictureBox control: S.N Method Name & Description 1 CancelAsync Cancels an asynchronous image load. 2 Load Displays an image in the picture box 3 LoadAsync Loads image asynchronously. 4 ToString Returns the string that represents the current picture box. PictureBoxControl Events : The following are some of the commonly used events of the PictureBox control: S.N Event Description 1 CausesValidationChanged Overrides the Control.CausesValidationChanged property. 2 Click Occurs when the control is clicked. 3 Enter Overrides the Control.Enter property. 4 FontChanged Occurs when the value of the Font property changes. 5 ForeColorChanged Occurs when the value of the ForeColor property changes. 6 KeyDown Occurs when a key is pressed when the control has focus. 7 KeyPress Occurs when a key is pressed when the control has focus.
  • 38. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 38 8 KeyUp Occurs when a key is released when the control has focus. 9 Leave Occurs when input focus leaves the PictureBox. 10 LoadCompleted Occurs when the asynchronous image-load operation is completed, been canceled, or raised an exception. 11 LoadProgressChanged Occurs when the progress of an asynchronous image-loading operation has changed. 12 Resize Occurs when the control is resized. 13 RightToLeftChanged Occurs when the value of the RightToLeft property changes. 14 SizeChanged Occurs when the Size property value changes. 15 SizeModeChanged Occurs when SizeMode changes. 16 TabIndexChanged Occurs when the value of the TabIndex property changes. 17 TabStopChanged Occurs when the value of the TabStop property changes. 18 TextChanged Occurs when the value of the Text property changes. Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ' Set the caption bar text of the form. Me.Text = "Prachi Sasankar" End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click PictureBox1.ClientSize = New Size(300, 300)
  • 39. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 39 PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage End Sub End Class 10. SCROLLBAR : The ScrollBar controls display vertical and horizontal scroll bars on the form. This is used for navigating through large amount of information. There are two types of scroll bar controls: HScrollBar for horizontal scroll bars and VScrollBar for vertical scroll bars. These are used independently from each other. Let's click on HScrollBar control and VScrollBar control from the Toolbox and place them on the form. ScrollBarControlProperties: The following are some of the commonly used properties of the ScrollBar control: S.N Property Description 1 AutoSize Gets or sets a value indicating whether the ScrollBar is automatically resized to fit its contents. 2 BackColor Gets or sets the background color for the control. 3 ForeColor Gets or sets the foreground color of the scroll bar
  • 40. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 40 control. 4 ImeMode Gets or sets the Input Method Editor (IME) mode supported by this control. 5 LargeChange Gets or sets a value to be added to or subtracted from the Value property when the scroll box is moved a large distance. 6 Maximum Gets or sets the upper limit of values of the scrollable range. 7 Minimum Gets or sets the lower limit of values of the scrollable range. 8 SmallChange Gets or sets the value to be added to or subtracted from the Value property when the scroll box is moved a small distance. 9 Value Gets or sets a numeric value that represents the current position of the scroll box on the scroll bar control. ScrollBar Control Methods : The following are some of the commonly used methods of the ScrollBar control: S.N Method Name & Description 1 OnClick Generates the Click event. 2 Select Activates the control. ScrollBar Control Events: The following are some of the commonly used events of the ScrollBar control: S.N Event Description 1 Click Occurs when the control is clicked. 2 DoubleClick Occurs when the user double-clicks the control.
  • 41. Prof.Prachi Sasankar - CONTROLS AND EVENTS VisualBasic.Net Sem-V BCA/MCA/BE 41 3 Scroll Occurs when the control is moved. 4 ValueChanged Occurs when the Value property changes, either by handling the Scroll event or programmatically. Ex: Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) _ Handles MyBase.Load 'create two scroll bars Dim hs As HScrollBar Dim vs As VScrollBar hs = New HScrollBar() vs = New VScrollBar() 'set properties hs.Location = New Point(10, 200) hs.Size = New Size(175, 15) hs.Value = 50 vs.Location = New Point(200, 30) vs.Size = New Size(15, 175) hs.Value = 50 'adding the scroll bars to the form Me.Controls.Add(hs) Me.Controls.Add(vs) ' Set the caption bar text of the form. Me.Text = "Prachi Sasankar" End Sub End Class