当点击form1的按钮时,想让form2窗体出现,但是每次form1都在,很头疼。
怎样才能实现点击按钮时,form2出现而form1隐藏,当关闭form2时,form出现啊?

解决方案 »

  1.   

    form1.hide;
    form2.show;以上假设2个窗体已经由创建了。楼主是不是这个意思啊?
      

  2.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation
    uses unit2;
    {$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
      form2.Show;
      form1.Hide;
    end;end.
    /////////////////////////////////////////////////////////unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs,unit1;type
      TForm2 = class(TForm)
        procedure FormClose(Sender: TObject; var Action: TCloseAction);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form2: TForm2;implementation{$R *.dfm}procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      form1.Show;
    end;end.
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      form2.Show;
      form1.Hide;
    end;procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      form1.Show;
    end;
      

  4.   

    控制好 Show 和 Close 的使用就行了在 Option 里把要 Show 和 Close 的窗体都拉到左边
    只要把不想见到的窗体的Visible属性设置为 False 就行了