Technology Programming

How to click-and-select a line in TMemo

Here's how to select a row (line) of text in a TMemo control by clicking on it:

Note:Drop a TMemo (Memo1) on a form and call the "SelectMemoLine" procedure from Memo's OnClick event:
~~~~~~~~~~~~~~~~~~~~~~~~~
procedure SelectMemoLine(Memo : TCustomMemo) ;
var
   Line : integer;
begin
   with Memo do
   begin
     Line := Perform(EM_LINEFROMCHAR, SelStart, 0) ;
     SelStart := Perform(EM_LINEINDEX, Line, 0) ;
     SelLength := Length(Lines[Line]) ;
   end;
end;

//Usage:
procedure TForm1.Memo1Click(Sender: TObject) ;
begin
   SelectMemoLine(Memo1) ;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~


If you are looking for more TMemo related tips: TMemo to the Max

Delphi tips navigator:
» How to focus a specific cell (by field name) in a DBGrid Delphi component
« How to start your favorite application directly from the Delphi IDE

Related posts "Technology : Programming"

The Importance Of Having a WordPress Business Theme

Programming

Website Design Is Necessary For Your Website

Programming

The Most effective On line Paid Survey Evaluation

Programming

Adelaide SEO - Links And Keywords, How Should They Be Used

Programming

C Programming Compilers for Microcontrollers

Programming

How Should A DJ Make Music Logo That Is Distinct And Cool?

Programming

Call to Action Concepts for Small Businesses

Programming

Microsoft Access Databases in Office 365

Programming

Why web design is crucial for producing world class websites

Programming

Leave a Comment