When I click with the mouse on a line of text of a memo, I want that line to be selected (highlighted). Is this possible?
Selecting text in a Delphi TMemo component is done by setting the SelStart and SelLength properties.
If you want to select the entire current line with a mouse click, start
by creating an OnClick event handler for the Memo.
Here's a source code example:
procedure TForm1.Memo1Click(Sender: TObject); var CurrentLine: integer; begin CurrentLine := Memo1.Perform(EM_LINEFROMCHAR, -1, 0); Memo1.SelStart := Memo1.Perform(EM_LINEINDEX, CurrentLine, 0); Memo1.SelLength := Length(Memo1.Lines[CurrentLine]); end;