首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

窗体作参数

2012-12-29 
窗体做参数procedureOpenOrCloseTuningFunctionOfPh(AForm :TFormClass)vari :integerBForm :TForm abso

窗体做参数


procedure  OpenOrCloseTuningFunctionOfPh(AForm :TFormClass);
var
  i :integer;
  BForm :TForm absolute AForm;
begin
    for i := 1 to 20 do
    begin
      TCheckBox(BForm.FindComponent('chk' + IntToStr(i))).Left := 1;
      TCheckBox(BForm.FindComponent('chk' + IntToStr(i))).Visible := True;
      TEdit(BForm.FindComponent('edt' + IntToStr(i))).Left := 15;
      TEdit(BForm.FindComponent('edt' + IntToStr(i))).Visible := True;
    end;
end;


我有多个窗体上有20个checkbox、edit
请问如何写公共函数,访问
以上这段代码怎么修改
[解决办法]
方便一点啊。。
[解决办法]
引用:
...
 cb:TCheckBox;
 et:TEdit;访问? 不太懂

马上结贴

你不喜欢添加多那两个变量的话,还可以这样:
procedure  OpenOrCloseTuningFunctionOfPh(AForm :TForm);
var i :integer;
begin
  for i := 1 to 20 do begin
    with TCheckBox(AForm.FindComponent('chk' + IntToStr(i))) do begin
      Left := 1;
      Visible := True;
    end;
    with TEdit(AForm.FindComponent('edt' + IntToStr(i))) do begin
      Left := 15;
      Visible := True;
    end;
  end;
end;

热点排行