delphi memo 通过行号 定位 指定行  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi memo 通过行号 定位 指定行


delphi memo 通过行号 定位 指定行

procedure TForm1.Button1Click(Sender: TObject);
var
  LineNumber, StartPos, LineLength: Integer;
begin
  LineNumber := 2;  // The line number to select (0-based)

  // Calculate the start position of the line
  StartPos := Memo1.Perform(EM_LINEINDEX, LineNumber, 0);

  // Calculate the length of the line
  LineLength := Memo1.Perform(EM_LINELENGTH, StartPos, 0);

  // Select the line
  Memo1.SelStart := StartPos;
  Memo1.SelLength := LineLength;

  // Set focus to the memo to show the selected line
  Memo1.SetFocus;
end;



推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.045003890991211 seconds