Show: Delphi C++
Display Preferences

Adding New Capabilities to a Class

From RAD Studio
Jump to: navigation, search

Go Up to Deriving New Classes


A common reason for creating new components is to add capabilities not found in existing components. When you do this, you derive the new component from either an existing component or an abstract base class, such as TComponent or TControl.

Derive your new component from the class that contains the closest subset of the features you want. You can add capabilities to a class, but you cannot take them away; so if an existing component class contains properties that you do not want to include in yours, you should derive from that component's ancestor.

For example, if you want to add features to a list box, you could derive your component from TListBox. However, if you want to add new features but exclude some capabilities of the standard list box, you need to derive your component from TCustomListBox, the ancestor of TListBox. Then you can recreate (or make visible) only the list-box capabilities you want, and add your new features.

Customizing a grid shows an example of customizing an abstract component class.

Personal tools
RAD Studio 10.2 Tokyo
In other languages
Previous Versions
Assistance