0

I have been looking for how to create multiple tabsheet where for every tabsheet I created has the same components therein. I understand how to create a new tabsheet, but what I need is to make tabsheet and all their child components.

I have tried to create an instance of the TForm and stick the TForm into tabsheet, but only these forms are attached to tabsheet. Not with their child components.

This is my programing code:

 procedure TmPenjualan.Button1OnClick(Sender: TObject);
 var
 Tab: TTabSheet;
 FormT: TForm;
 FrameT: TFrame;
 begin
  Tab := TTabSheet.Create(PageControlParent);
  Tab.PageControl := PageControlParent;
  FormT := TForm1.CreateNew(Tab);
  FormT.Parent := Tab;
  FormT.Show;
 end;

If I was wrong, please help me with specific sample code. Thanks in advance

Tommy Sayugo
  • 375
  • 2
  • 5
  • 16
  • 7
    Use a frame instead of a form. – Rudy Velthuis Aug 14 '16 at 03:31
  • 1
    @RudyVelthuis I don't understand how using frames instead of forms would solve OP's problem. The way I understand it, OP has attempted embedding such forms, but hasn't shown us any code, so we have no way of knowing where they went wrong. – Jerry Dodge Aug 14 '16 at 16:24
  • 1
    Frames can easily be made into components. Just put the same frame on each new sheet. What is so hard to understand? I have done it in several situations, and it works great. If it doesn't work, we would need to see an [mcve]. – Rudy Velthuis Aug 14 '16 at 17:12
  • @JerryDodge: frames are not forms. Frames are meant to be embedded, while forms are not. – Rudy Velthuis Aug 14 '16 at 17:14
  • Ask yourself, why do frames not have an `OnCreate` / `OnDestroy` event? Why does one have to take a back door to accomplish this? – Jerry Dodge Aug 15 '16 at 15:38
  • Hello All, Thanks for the comment. But this dont answer my question. Here i give you the code I was done. `procedure TmPenjualan.actTambahExecute(Sender: TObject); var Tab: TRzTabSheet; FormT: TForm; FrameT: TFrame; begin with fPenjualan do begin Tab := TRzTabSheet.Create(pcPenjualan); Tab.PageControl := pcPenjualan; FormT := TfNota.CreateNew(Tab); FormT.Parent := Tab; FormT.Show; end; end;` Maybe you can give me the right code if I was wrong – Tommy Sayugo Aug 16 '16 at 02:40
  • @Tommy Don't call CreateNew because that skips the dim file load. Use Create. – David Heffernan Aug 16 '16 at 06:01
  • @Tommy You might also consider using `TTabControl` which is intended for use when every page contains the same controls. – David Heffernan Aug 16 '16 at 09:54

0 Answers0