Unit 'StdCtrls' Package
[Overview][Constants][Types][Classes][Procedures and functions][Index] [#lcl]


[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Control used to display and edit multi-line text.


Source position: stdctrls.pp line 1020

type TMemo = class(TCustomMemo)


  property Align: TAlign;


Specifies the placement of the control on its Parent control.

  property Alignment: TAlignment;


The horizontal alignment for the text in the control (left, right, or centered).

  property Anchors: TAnchors;


The set of anchor definitions for this control.

  property BidiMode: TBiDiMode;


Indicates whether text controls use in bi-directional reading.

  property BorderSpacing: TControlBorderSpacing;


Determines the inner and outer border spacing for this control.

  property BorderStyle: TBorderStyle;


Indicates the line style drawn as a border around the control.

  property CharCase: TEditCharCase;


Controls the character case applied to values entered in the control.

  property Color: TGraphicsColor;


The background color of the control.

  property Constraints: TSizeConstraints;


Contains the minimum and maximum Width and Height for the control.

  property DoubleBuffered: Boolean;


Allows to reduce flicker in the painting of the control.

  property DragCursor: TCursor;


The cursor shape shown while the control is dragged.

  property DragKind: TDragKind;


The operation when the control is dragged - Drag or Dock.

  property DragMode: TDragMode;


Allows the user to drag the control.

  property Enabled: Boolean;


Determines whether the control responds to mouse or keyboard input.

  property Font: TFont;


The font to be used for text display in this control.

  property HideSelection: Boolean;


Determines if selected text to be hidden when the control does not have focus.

  property Lines: TStrings;


Contains the individual lines of text in the multi-line edit control.

  property MaxLength: Integer;


The maximum length of the value entered in Text, or 0 (zero) for unlimited length.

  property OnChange: TNotifyEvent;


Event handler signalled when the text for the control is changed.

  property OnClick: TNotifyEvent;


Notification handler for mouse clicks.

  property OnContextPopup: TContextPopupEvent;


Invoked when a context-sensitive pop-up menu is requested.

  property OnDblClick: TNotifyEvent;


Event Handler for double mouse clicks.

  property OnDragDrop: TDragDropEvent;


This handler determines the action on an drop onto this control, in a drag-drop operation.

  property OnDragOver: TDragOverEvent;


Event handler for a control being dragged over this control.

  property OnEditingDone: TNotifyEvent;


Event handler signalled when editing is done.

  property OnEndDrag: TEndDragEvent;


Notification handler for the end of a drag operation.

  property OnEnter: TNotifyEvent;


Handler for control receiving the focus.

  property OnExit: TNotifyEvent;


Handler for control losing the focus; This is a good place for checking the finished user input.

  property OnKeyDown: TKeyEvent;


Handler for keyboard key pressed.

  property OnKeyPress: TKeyPressEvent;


Handler for a character entered by the user.

  property OnKeyUp: TKeyEvent;


Event handler signalled when a key up event has occurred for the control.

  property OnMouseDown: TMouseEvent;


Event handler signalled when a mouse down event is handled for the control.

  property OnMouseEnter: TNotifyEvent;


Event handler signalled when the mouse pointer has entered the control.

  property OnMouseLeave: TNotifyEvent;


Event handler signalled when the mouse pointer has left the control.

  property OnMouseMove: TMouseMoveEvent;


Event handler for mouse movement within the control.

  property OnMouseUp: TMouseEvent;


Event handler signalled when a mouse up event is handled for the control.

  property OnMouseWheel: TMouseWheelEvent;


Event handler for mouse wheel turned.

  property OnMouseWheelDown: TMouseWheelUpDownEvent;


Event handler for downward movement of mouse wheel.

  property OnMouseWheelUp: TMouseWheelUpDownEvent;


Event handler for upward movement of the mouse wheel.

  property OnMouseWheelHorz: TMouseWheelEvent;


Event handler for horizontal movements of the mouse wheel.

  property OnMouseWheelLeft: TMouseWheelUpDownEvent;


Event handler signalled for left mouse wheel movements.

  property OnMouseWheelRight: TMouseWheelUpDownEvent;


Event handler signalled for right mouse wheel movements.

  property OnResize: TNotifyEvent;


Notification handler for a resize of the control.

  property OnStartDrag: TStartDragEvent;


Event handler for the start of a dragging operation.

  property OnUTF8KeyPress: TUTF8KeyPressEvent;


Handler for a character entered by the user.

  property ParentBidiMode: Boolean;


Indicates whether the BiDiMode settings in the Parent control are used.

  property ParentColor: Boolean;


Use the Color from the Parent control, when enabled.

  property ParentDoubleBuffered: Boolean;


Value for the DoubleBuffered property in a Parent control.

  property ParentFont: Boolean;


If True, the Font of the control will be the same as the one from the Parent. Default is True.

  property PopupMenu: TPopupMenu;


A context-sensitive menu that pops up when the right mouse button is clicked over this control.

  property ParentShowHint: Boolean;


If True, the value of ShowHint for the control will be the same as the one from the Parent. Default is True.

  property ReadOnly: Boolean;


Indicates if the user is prevented from changing the value for the Text in the control.

  property ScrollBars: TScrollStyle;


Defines the vertical and/or horizontal scrollbars used in the control.

  property ShowHint: Boolean;


Enables Hint display for the control.

  property TabOrder: TTabOrder;


Indicates the navigation order for the control when the user presses the Tab or Shift+Tab key.

  property TabStop: Boolean;


Enables keyboard navigation using the Tab or Shift+Tab keys.

  property Visible: Boolean;


Allows the control, and all of its children, to be displayed or hidden.

  property WantReturns: Boolean;


Allows the user to insert Return characters (line breaks) into the text.

  property WantTabs: Boolean;


Allows Tab characters to be entered into the text.

  property WordWrap: Boolean;


Allows long lines (paragraphs) to wrap into multiple display lines.





Control used to display and edit multi-line text.




The base class for multi-line text controls.




The base class for controls presenting editable text.




Implements a windowed control which can contain other child controls.




The base class for visible controls.







TMemo is a TCustomMemo descendant which implements a multi-line text edit control. TMemo sets the visibility for properties introduced in TCustomMemo, but does not introduce any new methods.

The textual values in the multi-line control can be accessed using the Lines property. An individual line of text can be accessed by its ordinal position in the list of values. For example:

// var sContent: String; ...
    sContent := AMemo.Lines[2];

This provides access to the third value in List (index positions are zero-based).

The values for all of the text in Lines can be retrieved as a single String using the Text property in the TStrings class instance. Each line of text is separated by the LineEnding character sequence for the host platform or operating system. For example:

// var sContent: String; ...
    sContent := AMemo.Lines.Text;

Please note: There is a difference in TCustomMemo / TMemo between the Text and Lines properties. Text is actually the Caption for the control as inherited from TControl. Lines is the multi-line TStrings instance specific to the memo control. Setting the control value using Text does NOT cause the Modified property to be updated. Setting the value using the Lines property does cause the Modified property to be updated.

This is important if an OnChange event handler is used to detect changes to the value in the control, and you need to identify whether the change was performed in program code. You can identify a programmatic change by manipulating the value in Modified.

For changes in program code, set Modified to False before setting the value using the Text property. If Modified is False when OnChange is signalled, the change occurred in program code. Modified can be set as desired in your program code after the value is assigned to Text. For example:

// use Modified and Text to track program changes
procedure TForm1.Button1Click(Sender: TObject);
  Memo1.Modified := False;
  Memo1.Text := 'Whiskey' + LineEnding + 'Tango' + LineEnding + 'Foxtrot';
  Memo1.Modified := True;

procedure TForm1.Memo1Change(Sender: TObject);
  if not TCustomMemo(Sender).Modified then
     StaticText1.Caption := 'Memo changed in code'
     StaticText1.Caption := 'Memo changed by user';

Changes entered by the user are applied when methods update the Lines property in the control. As a result, Modified is set to True. If Modified is True in OnChange, the change was triggered by user interaction with the control.

The value in Modified is retained when the control gains or loses focus whether by keyboard navigation or by using the mouse.

The text displayed in the control uses the attributes defined in the Font property. No capabilities are provided for formatting individual characters, words, or lines in the content for the control.

Both horizontal and vertical scrollbars can be used in the control. Use the ScrollBar property to define the scrollbars displayed for the control. It can be used to enable automatic scrollbars which are only displayed when the content for the control does not fit within its bounds.

Use the Append method to add a line to text to the values in Lines.

Use the WantTabs and WantReturns properties to determine whether the corresponding keys are captured and stored in Lines. This affects the way control messages are applied to the control.

Use WordWrap to indicate if the control should automatically wrap a line of text longer than the visible area for the control.

Applications should use TEdit for a single line edit control.

See also



How to use StdCtrls, ComCtrls or ExtCtrls.



The base class for multi-line text controls.



Implements an edit control with a single line of text.

CT Web help

CodeTyphon Studio