窗体里面有多个各种各样的组件,而且都是隐藏的。怎么把其中Name为MyEdit组件显示出来?

解决方案 »

  1.   

    tedit(MyEdit).Visible := True
      

  2.   

    var
      edit:Tcomponent;edit:=form1.findcomponent('MyEdit');
    if edit<>nil then
      edit.visible := true;
      

  3.   

    同意 阿琪一楼的兄弟,呵呵,MyEdit如果不是tedit怎么办  :)
      

  4.   

    for i:= 0 to self.ComponentCount - 1 do
        begin
          if (self.Components[i].name is MyEdit) then
            begin
              self.components[i].visible:=true;
            end;
        end;
    end;
      

  5.   

    for i:=0 to componentcount-1 do
      begin
        if (Components[i] is tedit) then
        begin
          if (Components[i] as tedit).name='Edit1' then
          begin
            (Components[i] as tedit).Visible:=true;
            exit;
          end;
        end;
      end;
      

  6.   

    const int EditBoxCount = 20;const int LeftCoordinate = 10;
    TForm1 *Form1;
    TEdit* pe[20];void __fastcall TForm1::FormCreate(TObject *Sender){
        const char* pszNamePrefix = "MyEdit";
        for (int i=0;i<EditBoxCount;i++)
        {
            pe[i] = new TEdit(this);
            pe[i]->Name = pszNamePrefix + IntToStr(i+1);
            pe[i]->Left = LeftCoordinate;
            pe[i]->Top = i*EditBoxCount;
            pe[i]->Parent = this;
        }    delete pszNamePrefix;
    }void __fastcall TForm1::FormDestroy(TObject *Sender){
      for (int i=0;i<EditBoxCount;i++)
        delete pe[i];
    }