Visual Basic.Net Forms: Properties, Methods, and Events


Visual Basic.Net provides both console applications and Windows applications. The Windows Form applications are created using the Windows forms. Here we are learning the visual forms and form properties, methods, and events.

VB.Net Forms

Create Visual Basic.Net Forms in Visual Studio

To create a form in VB.Net, open your Visual Studio and follow this step: File -> New Project -> Windows Forms Applications.

Before clicking the OK button choose the project location and provide a custom project name instead of WindowsApplication1.

Visual Basic.Net Forms

By clicking OK button, Visual Studio creates a project and displays a Form namely form1 as shown below.

Visual Basic.Net Forms

Every Form in the .Net framework contains a title bar, which displays the caption of the form, and three buttons to maximize, minimize and to close the window.

Visual Basic.Net Forms

VB.Net Forms Properties

Following table lists down the important properties of a form in



BackColor Set’s the background color for the form
BackgroundImage Set’s the background image for the form
Cursor Set the cursor image when it hovers over the form.
AllowDrop Specifies whether to accept the data dragged and dropped onto the form.
Font Get or sets the font used in the form
Locked Specifies whether the form is locked.
FormBorderStyle Get or set border style of a form
Text Provide the title for a Form Window
Control Box Determines whether the ControlBox is available by clicking the icon in the upper left corner of the window.
Icon Specifies icon for the window in the upper left corner.
MousePointer Sets the type of mouse pointer to be displayed when hovered over a specific area.
AcceptButton Get or sets the form button if the enter key is pressed.
Language Specifies the localized language.
Autoscroll Specifies whether to enable auto scrolling.
MaximizaBox Specifies whether to display the maximize option in the caption bar of the form.
IsMDIChild Defines whether the form is a container of Multiple Document Interface(MDI) child form.
MinimizeBox Specifies whether to display the minimize option in the caption bar of the form.

VB.Net Forms Methods

The commonly used form methods in Visual Basic.Net are given in the following table.

Method Name


Activate Activates the form and gives it focus.
ActivateMdiChild Activates the MDI child of a form.
BringToFront Brings the control to the front of the z-order.
CenterToParent Centers the position of the form within the bounds of the parent form.
CenterToScreen Centers the form on the current screen.
Close Closes the form.
Contains Retrieves a value indicating whether the specified control is a child of the control.
Focus Sets input focus to the control.
Hide Conceals the control from the user.
Refresh Forces the control to invalidate its client area and immediately redraw itself and any child controls.
ScaleControl Scales the location, size, padding, and margin of a control.
Select Activates the control.
SendToBack Sends the control to the back of the z-order.
SetAutoScrollMargin Sets the size of the auto-scroll margins.
SetDesktopBounds Sets the bounds of the form in desktop coordinates.
Show Displays the control to the user.
ShowDialog  Shows the form as a modal dialog box.

VB.Net Forms Events

The following table shows the mostly used Form events in Visual Basic.Net.



Activated Occurs when the form is activated in code or by the user.
Click Occurs when the form is clicked.
Closed Occurs before the form is closed.
Closing Occurs when the form is closing.
DoubleClick Occurs when the form control is double-clicked.
DragDrop Occurs when a drag-and-drop operation is completed.
Enter Occurs when the form is entered.
GotFocus Occurs when the form control receives focus.
KeyDown Occurs when a key is pressed while the form has focus.
KeyPress Occurs when a key is pressed while the form has focus.
KeyUp Occurs when a key is released while the form has focus.
Load Occurs before a form is displayed for the first time.
MouseDown Occurs when the mouse pointer is over the form and a mouse button is pressed.
MouseEnter Occurs when the mouse pointer enters the form.
MouseHover Occurs when the mouse pointer rests on the form.
MouseLeave Occurs when the mouse pointer leaves the form.
MouseMove Occurs when the mouse pointer is moved over the form.
Move Occurs when the form is moved.
Resize Occurs when the control is resized.
Scroll Occurs when the user or code scrolls through the client area.
Shown Occurs whenever the form is first displayed.
VisibleChanged Occurs when the Visible property value changes.
MouseUp Occurs when the mouse pointer is over the form and a mouse button is released.
MouseWheel Occurs when the mouse wheel moves while the control has focus.
LostFocus Occurs when the form loses focus.
HelpButtonClicked Occurs when the Help button is clicked.