Hi,
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...