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

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

By , About.com Guide

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

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. 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.