Control - Text Box

images\btn_ctrl_text.gif Text boxes are used to display text and to accept text entry from users. They may be used either dynamically to display text from various data sources or (something of a kludge, but very handy) as a means of creating fixed labels within forms, built-in documentation or other fixed text.

 

At run time, Windows will provide text boxes with the full set of keyboard and text navigation controls normally associated with text in Windows.

 

To Add a Text Box to a Form

 

1. Click on the Insert Text box button in the Tools toolbar.

2. Click and drag the location and size where it is to be created in the form.

3. Continue to create any additional text boxes desired.

4. Right click onto each text box and choose Properties from the context menu.

5. Set the properties for the text box as desired.

6. Move, resize and align the text box as desired.

 

Properties normally both return and set that particular property. The easiest way to edit properties is through the context menu's properties dialog for that control.

 

Some attributes of controls, such as their size or position are properties not of the control but of the container for the control, in this case the Form itself. To change the size or position of controls we can simply click on them and resize or drag them to a new position.

 

Keep in mind that programs can change the properties of controls at run time. Although this documentation is written as though the properties are set at design time using the Properties dialog for this control, there are many situations in which program code will be used to change a control's properties at run time.

 

Note: All properties and controls are prefaced with "wl" to indicate they are the windowless lightweight versions of the controls and properties settings. The "wl" prefix is suppressed in the documentation below to enhance legibility.

 

Properties

 

In addition to the properties listed below, a Control tab provides access to certain frequently used form properties for this control. See the Form Properties topic for information on those properties.

 

 

Text box

General

 

MousePointer

The type of mouse pointer displayed when over the text box. Choose from 16 different types plus a custom pointer

Alignment

Left justify, right justify, or center the text in the box.

Appearance

3D or Flat. 3D is the standard Windows look. Flat results in a rectangular square of background color with a foreground color border.

BorderStyle

FixedSingle (default) or None. None may be used with Flat Appearance to achieve an uncaptioned rectangle of background color.

OLEDragMode

DragManual (default) or DragAutomatic. DragManual means the program handles all OLE drag/drop operations, while DragAutomatic means the text box handles all OLE drag/drop operations

OLEDropMode

Set to None (default) if the text box does not accept OLE drops and is to display the No Drop cursor if an OLE drop is attempted. Set to Manual, the text box will trigger OLE drop events, allowing programs to handle the OLE drop operation in code.

ScrollBars

NoScrollbars, Horizontal, Vertical or Both. Set as desired to cause scroll bars to appear. Scroll bars appear only if MultiLine is set True (checked). Scroll bars will always appear in text boxes if enabled by this property even if the text does not extend beyond the borders of the box.

Enabled

True or False. True means the object can respond to user-generated events, false prevents it from responding. We can disable a control like a text box if we wish it to simply display information in a read-only way.

HideSelection

True or False. True means that highlighted text will not appear highlighted when the text box loses the focus. False means that highlighted text stays highlighted even when another form or dialog has the focus.

Locked

True or False. True means the user can scroll and highlight the text in the box but cannot change it. The program can change the text by modifying the text box's Text property. False (default) means users can edit the text in the text box.

MultiLine

True or False. True (checked) enables multiple lines of text. A multiple line text box will wrap text as the user enters text that extends past the text box. If a horizontal scroll bar is present text will not wrap. On a form with no default button, pressing ENTER in a multiple line text box will move the focus to the next line. If a default button exists in the form, the user must press CTRL Enter to move to the next line.

PasswordChar

Used to create password boxes in dialogs. Placing any character or string in this box sets that that character (or, the first character in the field) as the character to use for whatever is typed into that box. Virtually all applications use the asterisk character. If the MultiLine property is set True, setting the PasswordChar property will have no effect.

MaxLength

An integer that limits the number of characters that can be entered into the text box. Default is 0, meaning no limit. Text exceeding the given value in length will have extra characters truncated.

 

 

Text

 

Text

Text contents for this text box.

 

 

Color

 

Back Color

Color to be used for the text box's background.

Fore Color

Color to be used for the text box's foreground, the color of the text caption.

Color Set

Choose from Standard Colors (standard Windows non-dithered colors) or Windows System Colors. The latter will be defined by the user's Control Panel settings and is normally the setting used so that the form changes appearance like the rest of Windows if the Control Panel settings are changed.

Color Palette

Displays available colors. Click on the property to be changed to highlight it in the Properties pane, click on the desired color in the Color Palette pane and then press Apply.

Edit Custom Color

Change the custom color presented in the Color Palette when the Color Set is set to Windows System Colors.

 

 

Font

 

Properties

Font properties that may be changes.

Font

Choose a font installed on this system. It's wise to choose standard Windows fonts such as MS Sans Serif that are universally available.

Size

Size of font, in points.

Effects

Bold, Italic, Underline or Strikeout.

Sample Text

A preview of the selected settings.