Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7018019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:59:22+00:00 2026-05-27T22:59:22+00:00

I am using Delphi 7 and trying to create Delphi application having 5 buttons

  • 0

I am using Delphi 7 and trying to create Delphi application having 5 buttons on Main Form. Each button click will display another form with some components on it. The most components on subform for all button clicks are same. Which will be better way to do:

  1. to create new form on each click and and destroy it when it closed

    or

  2. to create one form once and use the same form for others (using directly ShowModal)?

But the problem in 2nd option is when I show that subform on 2nd time then the values of form remains same as when entered first time. Any solution to refresh it quickly?? or any other solution to display form?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:59:22+00:00Added an answer on May 27, 2026 at 10:59 pm

    The problem is that these forms are already auto-created when you add them to your app. You only need to create one of these, and remove its auto-creation.

    Go to Project > Options > Forms tab and look at the list of ‘Auto-Create forms’. Remove your sub-form from this list (adding it to the list on the right of ‘available forms’).

    Now you don’t need to create 5 different forms if you are showing them as modal, especially. You just need one…

    Unit1

    5 TButton controls, all sharing the same ButtonClick event (for this example) and whatever other controls you wish…

    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    
    type
      TForm1 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        Button3: TButton;
        Button4: TButton;
        Button5: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    uses
      Unit2;
    
    procedure TForm1.ButtonClick(Sender: TObject);
    var
      F: TForm2; //Declaration of the form
    begin
      F:= TForm2.Create(nil); //Creation of the form
      try
        F.ShowModal;
      finally
        F.Free; //Destruction of the form
      end;
    end;
    
    end.
    

    Note that I never once refer to the name Form2. Instead, I temporarily declare F: TForm2 just for the duration that I need it. If it wasn’t going to be modal, you would need a far different approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a 7z archive of certain files using Delphi 2009.
I am trying to create a code coverage tool using Delphi 2007. My general
I am building an application using Delphi 7. I have added one button on
I am using Delphi 2007 and I am trying to make record type file.
I am trying to connect to excel table from Delphi 7 using TAdoConnection component.
I am trying to send an e-mail using gmail account (Delphi 7, Indy 10)
I am using a multi-dimensional dynamic array in delphi and am trying to figure
I'm trying to get the Global Interface Table by using the following code (Delphi):
I'm trying to automate the build of a project in Delphi 2009. I'm using
When using Delphi IDE, it will silently change SQLConnection.Connected to true when populating field

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.