var
I: Integer;
begin
for I := 0 to Panel1.ComponentCount -1 do
begin
if (Panel1.Components) is TEdit then
TEdit(Panel1.Components).ReadOnly := True;
end;
end;
定义一个全局变量 V_readonly=true
在edit控件的Edit1KeyPress
procedure TForm1.Edit1KeyPress(Sender: TObject
var Key: Char);
begin
if key<>#13 then
if V_readonly=true then
key:=#0;
end;