Learn the most popular programming language of the most popular Operating System: Windows

Ad

Opening the Properties Window and Changing Form Properties

Besides a Project Explorer window, each form (or control) contains a Properties window.  As stated in Running a Visual Basic Program, a property is a named attribute of an object.  Properties are used to change the appearance or behavior of objects.

Figure 2.6 illustrates the default Properties dialog box for a form.  If this box is not visible, you can bring it into view by pressing the F4 function key, or choosing View, Properties Window.  With the form having the focus, press your right mouse button and drag down the Properties list.

Figure 2.6  
The Properties dialog box of a form contains the built-in form attributes that you can change.

Over 50 properties can be set for a form.  Although this number seems overwhelming at first, some properties are used so frequently that they represent an initial set to remember.

Form Properties

Caption

Name

BorderStyle

MinButton

MaxButton

ControlBox

WindowSize

BackColor

FontName

FontSize

FontBold

FontItalic

FontStrikethru

FontUnderline

ForeColor

StartUpPosition

To simplify this list somewhat, the items can be grouped by their uses:

  • Seven properties deal with the way in which the form or text appears on the display screen (Caption, BorderStyle, MinButton, MaxButton, ControlBox, WindowSize and StartUpPosition).
  • The identification of an object is specified by the Name property.
  • Font settings are controlled using the Fonts dialog box (FontName, FontSize, FontBold, FontItalic and FontStrikethru).
  • Color settings (ForeColor and BackColor) use a special palette.

There are three ways to change most property settings:

  • Click the property to highlight it, and enter (type in text) the new property setting in the text box.
  • Double-click the setting to view the alternative settings.
  • Click the down arrow to open the drop-down menu for property settings.

Properties for fonts and color launch a separate dialog box for you to enter settings.

Changing a Caption

The Caption property enables you to change the title that appears on the top of a form.  Instead of Form1, use the Caption property to add a title.  To change the caption, select Caption in the Properties dialog box and type the new title in the text box next to the property name.

Changing a Form Name

The Name property specifies the name of the form to be used in writing Visual Basic code. Remember the following rule: The name, not the caption, is the identifier.  When writing coded instructions, the Name property appears as the object name.  To change the name, select Name in the Properties dialog box and type the new name.

Changing the Border Style

The BorderStyle property enables you to change the appearance of the form’s border.  To change the border setting, double-click the current setting to reveal other choices, or click the down arrow to open the drop-down list of the six options.

If you are uncertain about the six border choices and their precise effects, click BorderStyle to give it the focus in the Properties dialog box, and press F1 (the Help function key).  Visual Basic Help displays the six style choices and explains their effects, as shown in Table 2.2.

Table 2.2 The Settings for the BorderStyle Property
Setting Style Description
0 None No border or border-related elements.
1 Fixed Single Can include Control menu icon, title bar, Maximize button, and Minimize button.  Resizable only using Maximize and Minimize buttons.
2 Sizable The default.  The size can be changed using any of the optional border elements listed for setting 1.
3 Fixed Dialog Can include Control menu icon and title bar; can’t include Maxiimize or Minimize buttons.  Not resizable.
4 FixedToolWindow Under 16-bit versions of Windows and Windows NT 3.51 and earlier, behaves like Fixed Single.  Does not display Maximize or Minimize buttons.  Not resizable.  Under Windows 95, displays the Close button and displays the title bar text in a reduced font size.  The form does not appear in the Windows 95 taskbar.
5 SizableToolWindow Under 16-bit version of Windows and Windows NT 3.5 and earlier, behaves like sizable.  Docs not display Maximize or Minimize buttons, Resizable.  Under Windows 95, displays the Close button and displays the title bar text in a reduced font size.  The form does not appear in the Windows 95 taskbar.

The online Help is one of Visual Basic’s strongest features.  Remember, the F1 key is your friend!  Use it often.  The language is just too vast to remember all of it.

Share:

No comments:

Post a Comment

Trending

Popular Posts

Search This Blog

Powered by Blogger.

Featured Post

Coded Statements and Methods

In the preceding procedure , you wrote several coded instructions, which introduced two different programming statements and a method: the D...

Recent Posts