1. Computing
Send to a Friend via Email

TEdit, TMaskEdit - Delphi Edit Control Usage Examples, Tips and Tricks

Edit controls display text to the user and allow the user to enter text. Delphi's TEdit and TMaskEdit are simple edit controls that include a single line text edit box in which you can type information. When the edit box has focus, a blinking insertion point appears. Learn how to use various edit controls in Delphi's VCL.

Advanced editing - TadpEdit component
Full source code of a TadpEdit Delphi component, an extension to the standard TEdit control with few powerful properties: ColorOnEnter (background color in focused state), Alignment (determines text alignment), and TabOnEnter (transforms Enter keypress to Tab).

Disable TEdit's Default PopUp (Context) Menu
When a user right-clicks on an Edit component at run time (or any other component that allows editing such as MaskEdit, Memo, DbEdit, etc.), by default the system's context menu pops up with options to undo, copy, paste, etc. Here's how to disable it.

Implementing "Overwrite" in TEdit Delphi Controls
The Windows (Delphi) TEdit and TMemo controls have no overwrite capability. It is possible to emulate this behavior however, by setting the SelLength property of the edit or memo control to one during the processing of the KeyPress event. This causes the character at the current position of the caret to be overwritten.

Disable CTRL+V Shortcut Key for a TCustomEdit
Sometimes you need to disallow a user from using keyboard shortcuts for common clipboard operations such as copy (CTRL+C) or paste (CTRL+V) while an edit control has the input focus.

Place a TEdit inside a TListBox to Enable Inplace Editing of Items
By design, a TListBox component displays a collection of items (string values) in a scrollable list. Items of a ListBox cannot be edited directly from "inside" the ListBox. If you ever needed to enable inplace editing of ListBox strings, here's a trick to place an ordinary TEdit inside a ListBox.

Catch a 'Tab Character' key stroke inside a TEdit
Here's how to react when TAB is pressed in a TEdit.

Generic Solution to Coloring the Focused Entry Control
To provide visually more attractive user-friendly interfaces for your Delphi applications, you could decide to change the background color (and maybe some other properties) of the currently selected control - the control that has the input focus. Of course, restoring to the original background color when the focus shifts to another control is also required.

Moving the Focus to the Next Edit Control
The MaxLenght property of a TCustomEdit descedant components (TEdit, TDBEdit, ...) specifies the maximum number of characters the user can enter into the edit control. Here's how to move immediately to the next control (in the tab order) when the max character length has been met...

Handle Dragging From a TListBox to a TEdit
The TListBox displays a list of string values in a scrollable list. If you need to enable a user to grab an item from a list box and drop it on an edit control you need to implement two edit's event handlers.

TNumEdit - Only Numeric Input Delphi Edit Control
TNumEdit is a component, just like TEdit, but it only accepts numerical input. You can adjust whether to accept positive or negative numbers or integer or decimals. You can also limit the input by using MinValue and/or MaxValue. Full source code.

How to Locate the Control was "Previously" Selected
Suppose you have two Edit (Edit1 and Edit2) boxes on a Form (Form1). Suppose you need to know what Edit box had the input focus (was selected) when you click a button (Button1).

The state of the Shift, Ctrl, Alt keys while a TEdit has Focus
The following functions can be used to check if the Shift, Ctrl or Alt key(s) are pressed...

Implementing "Cancel All Edits" for a Configuration-type Form in Delph
In your Delphi applications you have a configuration form you use to let the user change various parameters the application requires. The idea of this article is to show you how to implement such a "revert back" mechanism in your Delphi application.

©2014 About.com. All rights reserved.