I would like to create a TTabsheet which has to be create during run time. The TTabSheet has several components, but all of these components will be identical on every tab. Is it possible to create a "type" variable which will create these tabs every time?
Thanks
Yes. You could create inherited class from TTabSheet
You could also create a frame (TFrame) with your custom controls in design time and host it instances to all new tabs.
Just for the fun of it, here's a snippet of code I use periodically to add a tabsheet to a TPageControl that has a TMemo on it. This would be used, for example, if you've got a form that is used for editing text files. You'd call this to add a new tab with the filename as caption, then load the memo's
.Line
property from the file's contents.You call it by giving it the PageControl you want it to be added to, and a caption that's used in the tab.
Note that I save the new memo's pointer in
ts.Tag
so I can easily get to it later on through a cast.No subclassing is required. You can create any other components you might want on the tabsheet as well, after the
Result.Caption := caption
line. Just be sure to set their.Parent
property toResult
.The PageControl can be created either at design time or run-time.