RAD Studio |  |

Publishing Inherited Properties (Grid)

The abstract grid component, TCustomGrid, provides a large number of protected properties. You can choose which of those properties you want to make available to users of the calendar control.

To make inherited protected properties available to users of your components, redeclare the properties in the published part of your component's declaration.

For the calendar control, publish the following properties and events, as shown here:

Copy Code

    type
      TSampleCalendar = class(TCustomGrid)
      published
        property Align;  { publish properties }
        property BorderStyle;
        property Color;
        property Font;
        property GridLineWidth;
        property ParentColor;
        property ParentFont;
        property OnClick;  { publish events }
        property OnDblClick;
        property OnDragDrop;
        property OnDragOver;
        property OnEndDrag;
        property OnKeyDown;
        property OnKeyPress;
        property OnKeyUp;
      end;

Copy Code

    class PACKAGE TSampleCalendar : public TCustomGrid
    {
    .
    .
    .
    __published:
        __property Align ;                    // publish properties
        __property BorderStyle ;
        __property Color ;
        __property Font ;
        __property GridLineWidth ;
        __property ParentColor ;
        __property ParentFont ;
        __property OnClick ;                   // publish events
        __property OnDblClick ;
        __property OnDragDrop ;
        __property OnDragOver ;
        __property OnEndDrag ;
        __property OnKeyDown ;
        __property OnKeyPress ;
        __property OnKeyUp ;
    };

There are a number of other properties you could also publish, but which do not apply to a calendar, such as the Options property that would enable the user to choose which grid lines to draw.

If you install the modified calendar component to the Tool palette and use it in an application, you will find many more properties and events available in the calendar, all fully functional. You can now start adding new capabilities of your own design.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!