我要把光标设到最后,怎么办?
11 个解决方案
#1
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.SetFocus ;
memo1.SelStart :=length(memo1.Text );
memo1.SelLength :=0;
end;
begin
Memo1.SetFocus ;
memo1.SelStart :=length(memo1.Text );
memo1.SelLength :=0;
end;
#2
不行啊,我的memo是只读的
#3
你不会告诉我 Memo1.Enabled :=False吧,只读是Memo1.ReadOnly :=True
#4
放在一个Button.Click里就可以了,我是放在Form.Show里面的,不行
#5
当然是Memo1.ReadOnly :=True
#6
我这里测试过了可以的
#7
放到OnCreate里:
Show;
Memo1.SetFocus ;
memo1.SelStart :=length(memo1.Text );
memo1.SelLength :=0;
Show;
Memo1.SetFocus ;
memo1.SelStart :=length(memo1.Text );
memo1.SelLength :=0;
#8
Memo1.Lines.LoadFromFile('test.txt');
Memo1.SetFocus ;
memo1.SelStart :=length(memo1.Text );
memo1.SelLength :=0;
把这段放在Form.Show里可以?放在一个Button.Click里试过是可以的,Form.Show不行
我是窗口一打开就载入一个文件文件,然后想让光标定位到最后
Memo1.SetFocus ;
memo1.SelStart :=length(memo1.Text );
memo1.SelLength :=0;
把这段放在Form.Show里可以?放在一个Button.Click里试过是可以的,Form.Show不行
我是窗口一打开就载入一个文件文件,然后想让光标定位到最后
#9
OnCreat时能不能不Show,我的这个窗体是自动创建的
#10
你就不会变通一下吗:
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;
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;
#11
呵呵,我就是不能用局部的窗体变量:),因为这个窗体要常开着
不过在您的上面代码上加个尾巴就可以了,这样
Form.OnCreate里:
Show;
Memo1.SetFocus ;
memo1.SelStart :=length(memo1.Text );
memo1.SelLength :=0;
Hide;
:)
多谢
不过在您的上面代码上加个尾巴就可以了,这样
Form.OnCreate里:
Show;
Memo1.SetFocus ;
memo1.SelStart :=length(memo1.Text );
memo1.SelLength :=0;
Hide;
:)
多谢
#1
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.SetFocus ;
memo1.SelStart :=length(memo1.Text );
memo1.SelLength :=0;
end;
begin
Memo1.SetFocus ;
memo1.SelStart :=length(memo1.Text );
memo1.SelLength :=0;
end;
#2
不行啊,我的memo是只读的
#3
你不会告诉我 Memo1.Enabled :=False吧,只读是Memo1.ReadOnly :=True
#4
放在一个Button.Click里就可以了,我是放在Form.Show里面的,不行
#5
当然是Memo1.ReadOnly :=True
#6
我这里测试过了可以的
#7
放到OnCreate里:
Show;
Memo1.SetFocus ;
memo1.SelStart :=length(memo1.Text );
memo1.SelLength :=0;
Show;
Memo1.SetFocus ;
memo1.SelStart :=length(memo1.Text );
memo1.SelLength :=0;
#8
Memo1.Lines.LoadFromFile('test.txt');
Memo1.SetFocus ;
memo1.SelStart :=length(memo1.Text );
memo1.SelLength :=0;
把这段放在Form.Show里可以?放在一个Button.Click里试过是可以的,Form.Show不行
我是窗口一打开就载入一个文件文件,然后想让光标定位到最后
Memo1.SetFocus ;
memo1.SelStart :=length(memo1.Text );
memo1.SelLength :=0;
把这段放在Form.Show里可以?放在一个Button.Click里试过是可以的,Form.Show不行
我是窗口一打开就载入一个文件文件,然后想让光标定位到最后
#9
OnCreat时能不能不Show,我的这个窗体是自动创建的
#10
你就不会变通一下吗:
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;
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;
#11
呵呵,我就是不能用局部的窗体变量:),因为这个窗体要常开着
不过在您的上面代码上加个尾巴就可以了,这样
Form.OnCreate里:
Show;
Memo1.SetFocus ;
memo1.SelStart :=length(memo1.Text );
memo1.SelLength :=0;
Hide;
:)
多谢
不过在您的上面代码上加个尾巴就可以了,这样
Form.OnCreate里:
Show;
Memo1.SetFocus ;
memo1.SelStart :=length(memo1.Text );
memo1.SelLength :=0;
Hide;
:)
多谢