Component templates (Views: 54)


Do you usually drop a TDatabase component, associated with a TTable and a query... or a TEdit associated with a TButton... or some components that you usually put togheter in some of your projects?...


Well... there's a very cool feature in Delphi that allows you to put togheter some Components (EVEN WITH THE CODE OF THE EVENTS!), so that you can reuse them all later with a single click, like dropping one component, but it will drop the group of components (TEMPLATE) in your form

here's how:

In Delphi, start a new application
Drop as many components as you want on the main form, and set their properties and/or events
Select all the components that you want on your template
Choose from the Delphi menu Component | Create Component Template
Specify a name for your template , as a Delphi rule you may want to keep the "T" at the beginning of the name and change the rest to whatever you want
Specify the Palette page where you want your new template to be, if you put a non existant palette page, Delphi will create a new one for you
Delphi even lets you assign a new icon for your template
Click OK

You're set!!

you just created a template which appears on the palette of components, and you can drop on a form as many times as you want and they will be linked (like if you chose a TTable linked to a TDatabase) as you specified, and will have all the code that you put on the events, all with a single click

<< Back to main page