请问如何在memo的指定行的指定位置写入一个字符,假设行数和那行的位置可达!~
比如 想在第三行第两个字符的位置写入一个A

解决方案 »

  1.   

    呵呵。那就用到stringlist好了。
      

  2.   

    顶行设定:
    procedure TSRichEdit.SetTopLine(Value: integer);
    {Put selected line at top of memo}
    var
       tl: integer;
    begin
       tl := Value;
       if tl < 0 then   tl := 0;
       if tl > Lines.Count - 1 then   tl := Lines.Count - 1;
       SendMessage(Handle, EM_LINESCROLL, 0, tl - SendMessage(Handle, EM_GETFIRSTVISIBLELINE, 0, 0));
    end;光标定位到某一行:
    procedure TSRichEdit.SetCurrentLine(Value: integer);
    {Put caret on start of selected line}
    var
       cl: integer;
    begin
    cl := Value;
    {Restrict range to available lines}
    if cl < 0 then  cl := 0;
    if cl > Lines.Count - 1 then  cl := Lines.Count - 1;
    SelLength := 0;
    SelStart := SendMessage(Handle, EM_LINEINDEX, cl, 0);
    end;光标定位到某一列:
    procedure TSRichEdit.SetCurrentPosition(Value: integer);
    var
       cl: integer;
       cp: integer;
    begin
    cl := GetCurrentLine;
    cp := Value;
    if cp < 0 then  cp := 0;
    if (cp > Length(Lines[cl])) then  cp := Length(Lines[cl]);
    {Put caret in selected position}
    SelLength := 0;
    SelStart := SendMessage(Handle, EM_LINEINDEX, cl, 0) + cp;
    end;
    光标定位到指定的坐标点     richedit1.Perform(WM_LBUTTONDOWN, MK_LBUTTON, MakeLong(X, Y));    
      

  3.   

    sixgj(轰炸机)能不能说详细一点 :)
    DWGZ() 你是在richedit里的啊!~ 你这两个过程是不是自定义的? 我没有看太明白 能不能解释一下 谢谢
      

  4.   

    都一样所有的Hanle, 改成Memo1.Handle
      

  5.   

    var
      S: String;
    begin
      with Memo1 do
      begin
        S := Lines[1];
        Insert('A', S, 3);
        Lines[1]  := S;
      end;
    end;————————————————————————————————————
    宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
    ————————————————————————————————————
      

  6.   

    取Tmemo的当前行及跳转到指定行
    向Tmemo发送WM_KEYDOWN消息可实现跳转到指定行var i,line,lineDest:integer;
    //line表示取出的Memo1的当前行号
    //lineDest表示需要跳到的行号memo1.SetFocus;
    line:=1;
    lineDest:=2;//取当前行号line
    for i:=0 to length(memo1.text) do
    begin
    if memo1.Text[i]=chr(13) then line:=line+1;
    if memo1.SelStart<=i then break;
    end;//跳转到LineDest行
    if lineDest>line then
    begin
    for i:=line to lineDest-1 do
    postmessage(memo1.handle,WM_KEYDOWN,VK_DOWN,0);
    end
    else if lineDest<line then
    begin
    for i:=lineDest to line-1 do
    postmessage(memo1.handle,WM_KEYDOWN,VK_UP,0);
    end;