Mega Code Archive

 
Categories / Delphi / VCL
 

Set the focus to a particular line in Memo component

Title: Set the focus to a particular line in Memo component Question: How to set the focus to a particular line in Memo component? Answer: That's : Procedure SetMemoLine(Memo : TMemo; Line : Integer); Var i,iStart : Integer; iLength : Integer; Begin with Memo do begin if Line=Lines.Count then begin iStart:=Length(Text); iLength:=0; end else begin iLength:=Length(Lines[Line]); Dec(Line); iStart:=0; for I:=0 to Line do Inc(iStart,Length(Lines[I])); end; SelStart:=iStart; SelLength:=iLength; end; end;