Jump to content
The Code Captain

AutoNaming Events on TCollectionItem

Recommended Posts

In some of my TCollectionItem derived classes I override GetDisplayName so that the name shown in the IDE is meaningful for a user.  This is very useful.  Also when creating code for an event property on the TCollectionItem it uses that display name to name the method which is also very useful.

In one of my TCollectionItem classes I am representing the definition of data attributes in a structured record.  GetDisplayname was set to return the name of the attribute.  To assist users who want to see an overall view of the definition without having to inspect each property at user request I changed the display name to the SQL definition for that attribute.  This includes spaces, brackets and commas.  This works and is very helpful for the users that requested it, but now the events are named based on the default display name (So instead of having something like CardCodeWriter I have something like TITIODataAttribute64Writer).

Is there any way to supply a 'stub' for naming the events that's not the same as the result of the DisplayName?

Share this post


Link to post

The only methods your TCollectionItem can override to influence the Object Inspector are GetDisplayName() and GetNamePath().  If you want to customize how your event handlers are auto-generated, you will likely need a custom property editor derived from TMethodProperty (see how TMethodProperty.Edit() is implemented in $(BDS)\source\ToolsAPI\DesignEditors.pas).

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×