CSC 3 Week 3

VISUAL BASIC .NET Overview

  • Course Code: CSC 3

  • Level: Intermediate Programming


Topics Covered

  • Forms Control

  • Properties

  • Methods

  • Events

  • Basic Controls


Forms Control

  • Definition:

    • Refers to the core components of a graphical user interface (GUI) application.

    • A Form is the main container for all controls (e.g., buttons, labels, text boxes) and is the foundation for Windows desktop applications in VB.NET.


Object-Oriented Aspects of Forms

  • Object-Based Programming:

    • An object in Visual Basic is a user interface element created using toolbox controls.

    • The form itself acts as an object.

Control Elements

  1. Properties:

    • Describe the characteristics of an object.

  2. Methods:

    • Functions that allow the object to perform actions.

  3. Events:

    • Actions that occur due to user interactions.


Form Properties

  • Definition:

    • Form properties define appearance, behavior, and functionality.

  • Setting Properties:

    • Can be set during design time via the Properties window in Visual Studio or at runtime programmatically.

Key Form Properties

No.

Property

Description

1

AcceptButton

Automatically activates the specified button on Enter key press.

2

CancelButton

Activates the specified button on Esc key press.

3

AutoScale

Determines if controls are automatically scaled to font height (default True).

4

AutoScroll

Indicates if scroll bars are attached if the form is resized.

5

AutoScrollMinSize

Specifies minimum size before scroll bars are attached.

6

BackColor

Sets the form's background color.

7

BorderStyle

Determines the appearance of the form’s border.

8

ControlBox

Determines if the control menu is visible.

9

Enabled

Enables/disables the form's response to events.

10

Font

Specifies the font of the form.

11

Height

Sets the height of the form in pixels.

12

MinimizeBox

Hides the minimize button if set to False.

13

MaximizeBox

Hides the maximize button if set to False.

14

MinimumSize

Specifies the minimum form size when minimized.

15

MaximumSize

Specifies the maximum form size when maximized.

16

StartPosition

Initial positioning of the form when displayed.

17

Text

Text shown in the title bar of the form.

18

Width

Sets the width of the form in pixels.


Form Methods

  • Definition:

    • Methods are functions that perform specific actions with a form, controlling its behavior.

Commonly Used Form Methods

Sr.No.

Method

Description

1

Activate

Activates the form and gives it focus.

2

Close

Closes the form.

3

Hide

Conceals the form from the user.

4

Show

Displays the form to the user.

5

CenterToScreen

Centers the form on the current screen.


Form Events

  • Definition:

    • Events trigger specific actions upon user interactions and changes in the form’s state.

Commonly Used Form Events

Sr.No.

Event

Description

1

Activated

Occurs when the form is activated.

2

Click

Occurs when the form is clicked.

3

Closing

Occurs when the form is about to close.

4

Load

Occurs before the form is displayed for the first time.

5

Resize

Occurs when the form is resized.


Basic Controls

  • Definition:

    • VB.Net provides diverse controls for creating rich user interfaces, defined in the System.Windows.Forms namespace.

Common Controls

Sr.No.

Widget & Description

1

Forms

2

TextBox

3

Label

4

Button

5

ListBox

6

ComboBox

7

RadioButton

8

CheckBox

9

PictureBox

10

ProgressBar

11

ScrollBar

12

DateTimePicker

13

TreeView

14

ListView