Dynamically add tab sheets to page control and embed a form?

后端 未结 2 1567
轻奢々
轻奢々 2021-02-13 06:10

I\'m working on a module which consists of a page control. By default, this page control (TPageControl) shouldn\'t have any tab sheets (TTabSheet), but

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-13 06:48

    David Heffernan is right.

    Form2.Parent := TabSheet;
    Form2.Show;
    

    This code just means Form2's parent is TabSheet, not it's owner.

    You can create the form like this:

    Form2 := TForm2.Create(nil);
    

    and then free it by yourself. or you can create a form like this:

    Form2 := TForm2.Create(Form1);
    

    Form1 is the owner of Form2, and it will automatically free Form2 when itself is freed.

提交回复
热议问题