在DELPHI中有N个控件,不如有6个BUTTON,如何没次只能显示一个BUTTON,让其他的BUTTON隐藏呢?
也就是用到BUTTON1,其他都隐藏,谢谢

解决方案 »

  1.   

    显示属性 : visible
    如:
    button1.visible:=True;
    button2.visible:=False;
      

  2.   

    1 把所有要操作的 控件 visible:=False;
    2 要显示的 visible:=true
      

  3.   

    想不明白你要做什么,如果只是简单的隐藏只要用到控件的Visible属性就可以了。
      

  4.   

    参考一下,按数字键隐藏Button:procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    var i:integer;
    begin
      for i:=0 to self.ComponentCount-1 do
          if self.Components[i] is TButton then
                begin
                  if Pos(IntToStr(Key-48),Components[i].Name)>0 then
                    TButton(Components[i]).Enabled:=False
                  else
                    TButton(Components[i]).Enabled:=True;
                end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      Form1.KeyPreview:=True;
    end;
      

  5.   

    汗,应该是Visible
      if Pos(IntToStr(Key-48),Components[i].Name)>0 then
            TButton(Components[i]).Visible:=True
         else
            TButton(Components[i]).Visible:=False;