VB.Net Tutorials

Vb.Net Form

The Form is Most basic object of the VB.Net. Its provide the base Uppon which the graphical User Interface GUI of an application is created. We can place various control (objects) on the form to perform specific function.

Form Properties

1. AcceptButton

The button that's automatically activated when you press Enter, no matter which control has the focus at the time. Usually the OK button on a form is set as AcceptButton for a form.

2. CancelButton

The button that's automatically activated when you hit the Esc key.

Usually, the Cancel button on a form is set as CancelButton for a form.

3. AutoScale

This Boolean property determines whether the controls you place on the form are automatically scaled to the height of the current font. The default value of this property is True. This is a property of the form, but it affects the controls on the form.

4. AutoScroll

This Boolean property indicates whether scroll bars will be automatically attached to the form if it is resized to a point that not all its controls are visible.

AutoScrollMinSize

This property lets you specify the minimum size of the form, before the scroll bars are attached.

AutoScrollPosition

The AutoScrollPosition is the number of pixels by which the two scroll bars were displaced from their initial locations.

BackColor

Sets the form background color.

BorderStyle

The BorderStyle property determines the style of the form's border and the appearance of the form :

None :Borderless window that can't be resized.

  1. Sizable :This is default value and will be used for resizable window that's used for displaying regular forms.
  2. Fixed3D : Window with a visible border, "raised" relative to the main area. In this case, windows can't be resized.
  • FixedDialog : A fixed window, used to create dialog boxes.
  1. FixedSingle : A fixed window with a single line border.
  2. FixedToolWindow : A fixed window with a Close button only. It looks like the toolbar displayed by the drawing and imaging applications.
  3. SizableToolWindow : Same as the FixedToolWindow but resizable. In addition, its caption font is smaller than the usual.

ControlBox

By default, this property is True and you can set it to False to hide the icon and disable the Control menu.

Enabled

If True, allows the form to respond to mouse and keyboard events; if False, disables form.

Font

This property specify font type, style, size

 

HelpButton

Determines whether a Help button should be displayed in the caption box of the form.

Height

This is the height of the Form in pixels.

MinimizeBox

By default, this property is True and you can set it to False to hide the Minimize button on the title bar.

MaximizeBox

By default, this property is True and you can set it to False to hide the Maximize button on the title bar.

MinimumSize

This specifies the minimum height and width of the window you can minimize.

MaximumSize

This specifies the maximum height and width of the window you maximize.

Name

This is the actual name of the form.

Start Position

This property determines the initial position of the form when it's first displayed. It will have any of the following values :

  1. CenterParent: The form is centered in the area of its parent form.
  2. CenterScreen : The form is centered on the monitor.
  • Manual: The location and size of the form will determine its starting position.
  1. WindowsDefaultBounds: The form is positioned at the default location and size determined by Windows.
  2. WindowsDefaultLocation: The form is positioned at the Windows default location and has the dimensions you've set at design time.

Text

The text, which will appear at the title bar of the form.

Top, Left

These two properties set or return the coordinates of the form's top-left corner in pixels.

TopMost

This property is a True/False value that lets you specify whether the form will remain on top of all other forms in your application. Its default property is False.

Width

This is the width of the form in pixel.

Form Methods:

1.Activate

Activates the form and gives it focus.

2.ActivateMdiChild

Activates the MDI child of a form.

3.BringToFront

Brings the control to the front of the z-order.

4.Close

Closes the form.

5.Contains

Retrieves a value indicating whether the specified control is a child of the control.

6.Focus

Sets input focus to the control.

7.Hide

Conceals the control from the user.

8.Refresh

Forces the control to invalidate its client area and immediately redraw itself and any child controls.

9.Scale(SizeF)

Scales the control and all child controls by the specified scaling factor.

10.ScaleControl

Scales the location, size, padding, and margin of a control.

11.ScaleCore

Performs scaling of the form.

12.Select

Activates the control.

13.SendToBack

Sends the control to the back of the z-order.

14.Show

Displays the control to the user.

15.ShowDialog

Shows the form as a modal dialog box.

Form Events:

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.

LostFocus: Occurs when the form loses focus.

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.

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.

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.

 

Watch Video Tutorial of This Lesson