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 583715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:49:18+00:00 2026-05-13T14:49:18+00:00

I have 2 forms. Form1 with one panel and 2 buttons (pnl1, btnShowTree and

  • 0

I have 2 forms. Form1 with one panel and 2 buttons (pnl1, btnShowTree and btnAddItems). There is also Form2 which contains Treeview (tv1).

Please see short code below to understand this little demonstration:

procedure TForm1.btnShowTreeClick(Sender: TObject);
begin
   with Form2 do
   begin
   tv1.Items.clear;
   Tv1.Items.AddChild(nil, '1.' );
   Tv1.Items.AddChild(nil, '2.' );
   Tv1.Items.AddChild(nil, '3.' );
   Form2.Parent:=pnl1;
   Form2.BorderStyle:=bsNone;
   Form2.show;
   end;
end;

procedure TForm1.btnAddItemsClick(Sender: TObject);
begin
 with Form2 do
   begin
   BorderStyle:=bsSizeable;  // here it works wrong
   tv1.Items.clear;
   Tv1.Items.AddChild(nil, 'A.' );
   Tv1.Items.AddChild(nil, 'B.' );
   Tv1.Items.AddChild(nil, 'C.' );
 //  BorderStyle:=bsSizeable;  here it works fine. WHY ?????  
   Form2.Show;
   end;
end;

procedure TForm2.btnCloseForm2Click(Sender: TObject);
begin
Parent:=nil;   
Hide;          
// when I exchange instructions order  like:
// Hide;
// Parent:=nil;
// I get the same problem  with improperly nested BorderStyle:=bsSizeable; I have 
// only blur idea why it is so...
end;

I expected, that when I click on btnAddItems I will see 3 items (A. B. C.). But it will show 6 items, because the previous ones are not deleted !!! can anybody thow a light on it, ’cause I stucked here for hours to make program work well, but I still have not the thiniest idea what I do wrong…

  • 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-13T14:49:19+00:00Added an answer on May 13, 2026 at 2:49 pm

    Changing the BorderStyle at runtime means that the window has to be destroyed and recreated. This means that the VCL has to store the content of whatever controls are on the form (like your TTreeView), destroy the form, create the form with the new BorderStyle, recreate all the controls on the form, and then restore all the content.

    You’re probably using an older version of Delphi (see note below) that doesn’t properly remove the stored content from memory. @M Schenkel is using a later version that does.

    The solution, of course, is to stop changing the BorderStyle at runtime, which will stop causing the form to be destroyed and recreated. 🙂 I’ve been programming with Delphi starting with version 1 and continuing through the current Delphi 2010, and in all that time I have never once had a need to change BorderStyle at runtime.

    NOTE: When posting a Delphi question, you should always indicate what version of Delphi you’re using. Differences in Delphi version means differences in the VCL, and a problem can be caused by different things in those different versions. Knowing what version of Delphi you’re using makes solving your problem or answering your question easier.

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

Sidebar

Related Questions

I have a simple form with one text box and a panel with three
I have a form with a split panel. In the one split are a
The background In .NET Windows Forms (2.0) radio buttons are automatically grouped by their
I'm building a Windows Forms form in C# with various elements in a panel
I have what should be a fairly simple ASP.NET question, and one I thought
In one of my projects I need to build an ASP.NET page and some
I have a legacy system where I want to improve the user experience. On
I have a form that works in 'sections' that I will refer to as
I'm using the fantastic jquery .validate plugin from Jörn Zaefferer at bassistance I'm using

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.