有个CaretPos属性,但是是只读的,
我要把光标设到最后,怎么办?

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    Memo1.SetFocus ;
    memo1.SelStart :=length(memo1.Text );
    memo1.SelLength :=0;
    end;
      

  2.   

    你不会告诉我 Memo1.Enabled :=False吧,只读是Memo1.ReadOnly  :=True
      

  3.   

    放在一个Button.Click里就可以了,我是放在Form.Show里面的,不行
      

  4.   

    当然是Memo1.ReadOnly  :=True
      

  5.   

    放到OnCreate里:
    Show;
    Memo1.SetFocus ;
    memo1.SelStart :=length(memo1.Text );
    memo1.SelLength :=0;
      

  6.   

    Memo1.Lines.LoadFromFile('test.txt');
    Memo1.SetFocus ;
    memo1.SelStart :=length(memo1.Text );
    memo1.SelLength :=0;把这段放在Form.Show里可以?放在一个Button.Click里试过是可以的,Form.Show不行
    我是窗口一打开就载入一个文件文件,然后想让光标定位到最后
      

  7.   

    OnCreat时能不能不Show,我的这个窗体是自动创建的
      

  8.   

    你就不会变通一下吗:var
      form2: TForm1;
    begin
      form2 := TForm1.Create(Self);
      with form2 do
      begin
        Show;
        Memo1.Lines.LoadFromFile('test.txt');
        memo1.SelStart := length(memo1.Text);
        memo1.SelLength := 0;
        Memo1.SetFocus;
      end;
    end;
      

  9.   

    呵呵,我就是不能用局部的窗体变量:),因为这个窗体要常开着
    不过在您的上面代码上加个尾巴就可以了,这样Form.OnCreate里:Show;
    Memo1.SetFocus ;
    memo1.SelStart :=length(memo1.Text );
    memo1.SelLength :=0;
    Hide;:)
    多谢