Scalabium Software

SMReport Autogenerated
Knowledge for your independence'.
Home Delphi and C++Builder tips

#34: How can I change alignment for TEdit

Sometimes you need change the text alignment in standard TEdit component.
For some reason the developers in Microsoft decided, that for data editing in single line we do not need to change alignment and haven't provided such possibility:(

But sometimes I need it! For example, I like view a numbers with right alignment...

If you need it too then this delphi tip for you:

type TEditAlignment = class(TCustomEdit)
    { Protected declarations }
    procedure CreateParams(var Params: TCreateParams); override;

procedure TEditAlignment.CreateParams(var Params: TCreateParams);
const Alignments: array[TAlignment] of Longint =
  inherited CreateParams(Params);

  Params.Style := Params.Style or ES_MULTILINE or

In Windows 98 you can set a Params.Style without ES_MULTILINE flag and it too will work.

Also after such edit control can't correctly work with PasswordChar <> #0 (but I think for password input it's not necessary to change alignment).

PS: remark, that after that your TEdit is not "real" edit control - now is a control like "memo" but single line... Of course, you can use a standard TMemo component with height equal to one line.

PPS: You can download our freeware TTypedEdit component with extended possibilities for control of user typing, button in right side of edit, alignment and more

Published: October 22, 1999

See also
ABA Picture Convert
Viewer for MS Outlook Messages
Paradox to MS Access converter
Protected Storage Viewer
Excel Web-stream
Metafile Convert
Fast Document Viewer
Excel Reader (dll)

Contact to webmaster


Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2024, Scalabium Software. All rights reserved.

SMExport/SMImport suites