1. Home
  2. Computing & Technology
  3. Delphi Programming

How to add the "Select All (CTRL+A)" functionality to TMemo/TDBMemo

By Zarko Gajic, About.com

Here's how to implement the code for the CTRL+A key combination ("Select All") for TMemo or TDBMemo:

~~~~~~~~~~~~~~~~~~~~~~~~~
Just drop a memo (Memo1:TMemo) on a form (Form1:TForm) and handle the OnKeyDown event for Memo1 as:

procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word;
   Shift: TShiftState) ;
begin
   if (Key = Ord('A')) and (ssCtrl in Shift) then
   begin
     TMemo(Sender).SelectAll;
     Key := 0;
   end;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~
Note: here's how to check the state of CTRL, ALT and SHIFT keys.

Delphi tips navigator:
» How to encrypt a string in Delphi for .NET
« How to Minimize ALL the windows on the Desktop

Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Using VCL Components
  5. TMemo, TRichEdit
  6. How to add the "Select All (CTRL+A)" functionality to TMemo/TDBMemo

©2009 About.com, a part of The New York Times Company.

All rights reserved.