The Edit Control (TEdit)

Hierarchy: TObject - TPersistent - TComponent - TControl - TWinControl - TCustomEdit - TEdit

The Edit control allows input of text by the user of a program. It also allows output of text into an edit box.

Much of the input into a program entered from a keyboard, from edit boxes, combo boxes and list boxes, is in text form. Where numbers are input from the keyboard they will have to be converted from text format to the internal numeric format. Decisions have to be made about how data will be processed and stored, whether, for example, numbers and dates will be stored as text and converted to numbers later or, alternatively, stored as numbers and converted to text as required.

String input can be converted to numbers with functions such as:

Numeric data can be converted to text with the reverse functions:

(See the section on numeric conversion functions for further details.)

Major Properties

AutoSelect

If True then the text in the edit control is automatically selected when the control gets focus.

BorderStyle

This can be a single line, so the edit box stands out, or none, so it merges with the form background.

CharCase

Forces contents of edit control to a particular case. Possible values of CharCase are:

ecLowerCase - text converted to lowercase.
ecNormal  - text not forced into any case.
ecUpperCase - text converted to uppercase.

When CharCase is set to ecLowerCase or ecUpperCase, the case of characters is converted as the user types them into the edit control. 

For example:

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
 if CheckBox1.State=cbChecked then
  Edit1.CharCase:=ecUpperCase
 else
 if CheckBox1.State=cbUnchecked then
  Edit1.CharCase:=ecLowerCase;
end;

Major Methods

Clear

clear the contents of a control such as an edit box

CopyToClipboard

copies contents of control to clipboard

SetFocus

gives the focus to a control such as an edit box.

Create

creates an edit box, should you need to add one from inside a program rather than adding one to a form at design-time.

PasteFromClipboard

pastes text from clipboard into edit box

Back to Tutorial

Back to Palette List