用户单击Edit时,在Edit的Enter事件中,如何选择Edit的内容。

程晨c 2010-08-02 04:10:05
用户单击Edit时,在Edit的Enter事件中,如何选择Edit的内容。
测试了如下两种方法都不行。

procedure TForm1.Edit1Enter(Sender: TObject);
begin
edit1.SelectAll;
end;

procedure TForm1.Edit1Enter(Sender: TObject);
begin
edit1.SelStart:=0;
edit1.SelLength:=length(edit1.Text);
end;
...全文
78 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
程晨c 2010-08-02
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 bdmh 的回复:]
Delphi(Pascal) code
procedure TForm1.Edit1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Edit1.SelectAll;
end;
[/Quote]

OK
bdmh 2010-08-02
  • 打赏
  • 举报
回复
procedure TForm1.Edit1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Edit1.SelectAll;
end;
程晨c 2010-08-02
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 seleron 的回复:]
引用 1 楼 yangjing41 的回复:
Delphi(Pascal) code

procedure TForm1.edt1KeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then //按下回车键
edt1.SelectAll;
end;



是鼠标单击,不是回车键
[/Quote]

用户是要在鼠标单击是全部选中
程晨c 2010-08-02
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 yangjing41 的回复:]
Delphi(Pascal) code

procedure TForm1.edt1KeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then //按下回车键
edt1.SelectAll;
end;
[/Quote]


是鼠标单击,不是回车键
yangjing41 2010-08-02
  • 打赏
  • 举报
回复

procedure TForm1.edt1KeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then //按下回车键
edt1.SelectAll;
end;

5,926

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧