Modifying Existing Controls

From RAD Studio
Jump to: navigation, search

Go Up to Creating Components

The simplest way to create a component is to customize an existing one. You can derive a new component from any of the components provided in the component library.

Some controls, such as list boxes and grids, come in several variations on a basic theme. In these cases, the component library includes an abstract class (with the word "custom" in its name, such as TCustomGrid) from which to derive customized versions.

For example, you might want to create a special list box that does not have some of the properties of the standard TListBox class. You cannot remove (hide) a property inherited from an ancestor class, so you need to derive your component from something above TListBox in the hierarchy. Rather than force you to start from the abstract TWinControlclass and reinvent all the list box functions, the component library provides TCustomListBox, which implements the properties of a list box but does not publish all of them. When you derive a component from an abstract class like TCustomListBox, you publish only the properties you want to make available in your component and leave the rest protected.

The section Creating Properties - Overview explains publishing inherited properties. The section Modifying an Existing Component - Overview and the section Customizing a Grid - Overview show examples of modifying existing controls.

See Also