Categories in the Object Inspector (Views: 100)
In Delphi 5 the object inspector allow us to view properties and events by categories. We can instruct Delphi which category the properties and events of our components belongs to and even to create our own categories.
1. To instruct Delphi which category a property belongs to:
We have to do that in the Register procedure. The function RegisterPropertyInCategory has four overloaded versions. This is one of them. In this version we instruct Delphi to assign the property "Version" of our component "TMyButton" to the "TMiscellaneousCategory" standard category.
RegisterPropertyInCategory(TMiscellaneousCategory, TMyButton, 'Version');
Search Delphi help for more information about other overloaded versions of this function.
2.To create our own category:
We have to create a new class and derive it from TPropertyCategory or one of the existing categories (for example TMiscellaneousCategory). Then, we need to override the Name class function. The result value is the name shown by the object inspector.
TMyCategory = class(TPropertyCategory)
class function Name: string; override;
class function TMyCategory.Name: string;
Result := 'My Category';
Then we could use our new category.
RegisterPropertyInCategory(TMyCategory, TMyButton, 'Version');
You can also use RegisterPropertiesInCategory to register more than one property with one category at a time.
<< Back to main page