delphi显示Edit
Form上有Edit控件20个Edit1~~~Edit20,其中Edit1~~Edit20的visible属性为false,在edit21中输入一个数,比喻20,则edi...
Form上有Edit控件20个Edit1~~~Edit20,其中Edit1~~Edit20的visible属性为false,在edit21中输入一个数,比喻20,则edit1~edit20的visible属性变为true;输入5则edit~edit5的visible属性变为true,请问如何实现?多谢了~~
展开
2个回答
展开全部
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit20: TEdit;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
Edit11: TEdit;
Edit12: TEdit;
Edit13: TEdit;
Edit14: TEdit;
Edit15: TEdit;
Edit16: TEdit;
Edit17: TEdit;
Edit18: TEdit;
Edit19: TEdit;
Edit21: TEdit;
procedure Edit21Change(Sender: TObject);
procedure visb(c:DWORD;ed:array of TEdit);//自定义的过程
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure tform1.visb(C:DWORD;ed:array of TEdit);//自定义的过程
var
j:DWORD;
begin
if c=20 then
begin
for j:=1 to High(ed) do
begin
ed[j].Visible:=true;
end;
end
else
begin
for j:=0 to c do
begin
Ed[j].Visible:=True;
end;
if c=20 then Exit
else
begin
for j:=c to High(ed) do
begin
Ed[j].Visible:=False;
end;
end;
end;
end;
procedure TForm1.Edit21Change(Sender: TObject);
var
//edit:TEdit;
i:DWORD;
Edt:array [1..20] of TEdit;//=(Edit2,Edit3,Edit4,Edit5,Edit6,Edit7);因为是新手,,这里赋值不成功所以用下面的方式赋值
begin
Edt[1]:=Edit1;
Edt[2]:=Edit2;
Edt[3]:=Edit3;
Edt[4]:=Edit4;
Edt[5]:=Edit5;
Edt[6]:=Edit6;
Edt[7]:=Edit7;
Edt[8]:=Edit8;
Edt[9]:=Edit9;
Edt[10]:=Edit10;
Edt[11]:=Edit11;
Edt[12]:=Edit12;
Edt[13]:=Edit13;
Edt[14]:=Edit14;
Edt[15]:=Edit15;
Edt[16]:=Edit16;
Edt[17]:=Edit17;
Edt[18]:=Edit18;
Edt[19]:=Edit19;
Edt[20]:=Edit20;
if Edit21.Text='' then
begin
for i:=1 to High(edt) do
begin
Edt[i].Visible:=False;
end;
end
else
begin
case StrToInt(Edit21.Text) of
1:
begin
Visb(StrToInt(Edit21.Text),Edt);//从这里开始都是调用上面的过程
end;
2:
begin
Visb(StrToInt(Edit21.Text),Edt);
end;
3:
begin
Visb(StrToInt(Edit21.Text),Edt);
end;
4:
begin
Visb(StrToInt(Edit21.Text),Edt);
end;
5:
begin
Visb(StrToInt(Edit21.Text),Edt);
end;
6:
begin
Visb(StrToInt(Edit21.Text),Edt);
end;
7: Visb(StrToInt(Edit21.Text),Edt);
8: Visb(StrToInt(Edit21.Text),Edt);
9: Visb(StrToInt(Edit21.Text),Edt);
10: Visb(StrToInt(Edit21.Text),Edt);
11: Visb(StrToInt(Edit21.Text),Edt);
12: Visb(StrToInt(Edit21.Text),Edt);
13: Visb(StrToInt(Edit21.Text),Edt);
14: Visb(StrToInt(Edit21.Text),Edt);
15: Visb(StrToInt(Edit21.Text),Edt);
16: Visb(StrToInt(Edit21.Text),Edt);
17: Visb(StrToInt(Edit21.Text),Edt);
18: Visb(StrToInt(Edit21.Text),Edt);
19: Visb(StrToInt(Edit21.Text),Edt);
20: Visb(StrToInt(Edit21.Text),Edt);
else
begin
for i:=1 to High(edt) do
begin
Edt[i].Visible:=False;
end;
end;
end;
end;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit20: TEdit;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
Edit11: TEdit;
Edit12: TEdit;
Edit13: TEdit;
Edit14: TEdit;
Edit15: TEdit;
Edit16: TEdit;
Edit17: TEdit;
Edit18: TEdit;
Edit19: TEdit;
Edit21: TEdit;
procedure Edit21Change(Sender: TObject);
procedure visb(c:DWORD;ed:array of TEdit);//自定义的过程
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure tform1.visb(C:DWORD;ed:array of TEdit);//自定义的过程
var
j:DWORD;
begin
if c=20 then
begin
for j:=1 to High(ed) do
begin
ed[j].Visible:=true;
end;
end
else
begin
for j:=0 to c do
begin
Ed[j].Visible:=True;
end;
if c=20 then Exit
else
begin
for j:=c to High(ed) do
begin
Ed[j].Visible:=False;
end;
end;
end;
end;
procedure TForm1.Edit21Change(Sender: TObject);
var
//edit:TEdit;
i:DWORD;
Edt:array [1..20] of TEdit;//=(Edit2,Edit3,Edit4,Edit5,Edit6,Edit7);因为是新手,,这里赋值不成功所以用下面的方式赋值
begin
Edt[1]:=Edit1;
Edt[2]:=Edit2;
Edt[3]:=Edit3;
Edt[4]:=Edit4;
Edt[5]:=Edit5;
Edt[6]:=Edit6;
Edt[7]:=Edit7;
Edt[8]:=Edit8;
Edt[9]:=Edit9;
Edt[10]:=Edit10;
Edt[11]:=Edit11;
Edt[12]:=Edit12;
Edt[13]:=Edit13;
Edt[14]:=Edit14;
Edt[15]:=Edit15;
Edt[16]:=Edit16;
Edt[17]:=Edit17;
Edt[18]:=Edit18;
Edt[19]:=Edit19;
Edt[20]:=Edit20;
if Edit21.Text='' then
begin
for i:=1 to High(edt) do
begin
Edt[i].Visible:=False;
end;
end
else
begin
case StrToInt(Edit21.Text) of
1:
begin
Visb(StrToInt(Edit21.Text),Edt);//从这里开始都是调用上面的过程
end;
2:
begin
Visb(StrToInt(Edit21.Text),Edt);
end;
3:
begin
Visb(StrToInt(Edit21.Text),Edt);
end;
4:
begin
Visb(StrToInt(Edit21.Text),Edt);
end;
5:
begin
Visb(StrToInt(Edit21.Text),Edt);
end;
6:
begin
Visb(StrToInt(Edit21.Text),Edt);
end;
7: Visb(StrToInt(Edit21.Text),Edt);
8: Visb(StrToInt(Edit21.Text),Edt);
9: Visb(StrToInt(Edit21.Text),Edt);
10: Visb(StrToInt(Edit21.Text),Edt);
11: Visb(StrToInt(Edit21.Text),Edt);
12: Visb(StrToInt(Edit21.Text),Edt);
13: Visb(StrToInt(Edit21.Text),Edt);
14: Visb(StrToInt(Edit21.Text),Edt);
15: Visb(StrToInt(Edit21.Text),Edt);
16: Visb(StrToInt(Edit21.Text),Edt);
17: Visb(StrToInt(Edit21.Text),Edt);
18: Visb(StrToInt(Edit21.Text),Edt);
19: Visb(StrToInt(Edit21.Text),Edt);
20: Visb(StrToInt(Edit21.Text),Edt);
else
begin
for i:=1 to High(edt) do
begin
Edt[i].Visible:=False;
end;
end;
end;
end;
end;
end.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在Edit21的OnExit事件中写
procedure TForm1.Edit21Exit(Sender: TObject);
var
i: Integer;
begin
for i := 1 to StrToInt(Edit6.Text) do // Iterate
begin
TEdit(Self.FindComponent('Edit' + IntToStr(i))).Visible := True;
end; // for
end;
procedure TForm1.Edit21Exit(Sender: TObject);
var
i: Integer;
begin
for i := 1 to StrToInt(Edit6.Text) do // Iterate
begin
TEdit(Self.FindComponent('Edit' + IntToStr(i))).Visible := True;
end; // for
end;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询