- Posts: 51
- Thank you received: 0
×
Discussions for CodeTyphon Object Pascal Programming Language
Question Custom component and RTTI ImageIndex property
- Roman
- Topic Author
- Offline
- Junior Member
-
Less
More
2 years 6 months ago - 2 years 6 months ago #14138
by Roman
Custom component and RTTI ImageIndex property was created by Roman
Hello!
I just can’t understand what needs to be done with the ImageIndex property in my own component, so that in the property editor instead of the image number a drop-down list with images is displayed.
How to make it like this:
I just can’t understand what needs to be done with the ImageIndex property in my own component, so that in the property editor instead of the image number a drop-down list with images is displayed.
TMyComp = class(TComponent)
{ ... any methods and fields ...}
published
property ImageList : TCustomImageList read FImageList write SetImageList;
property ImageIndex : TImageIndex read FImageIndex write SetImageIndex default -1; // IDE Property Editor show only numbers, not images!
end;
How to make it like this:
Attachments:
Last edit: 2 years 6 months ago by Roman.
Please Log in or Create an account to join the conversation.
- Roman
- Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 51
- Thank you received: 0
2 years 6 months ago #14150
by Roman
Replied by Roman on topic Custom component and RTTI ImageIndex property
I helped myself 
So that in the IDE property editor of custom component it is possible to select ImageIndex by image from associated ImageList, you need to register your own editor of the Image Index property:
Important: property names must be correct, i.e. Images and ImageIndex, as written in RegisterPropertyEditor.

So that in the IDE property editor of custom component it is possible to select ImageIndex by image from associated ImageList, you need to register your own editor of the Image Index property:
type
TMyImageIndexEditor = class(TImageIndexPropertyEditor )
protected
function GetImageList: TCustomImageList; override;
end;
function TMyImageIndexEditor.GetImageList: TCustomImageList;
begin
Result := (GetComponent(0) as TMyComponent).FImageList
end;
procedure Register;
begin
RegisterComponents('My Tool Tab',[TMyComponent]);
RegisterPropertyEditor(TypeInfo(TImageIndex), TMyComponent, 'ImageIndex', TMyImageIndexEditor);
end;
Important: property names must be correct, i.e. Images and ImageIndex, as written in RegisterPropertyEditor.
Please Log in or Create an account to join the conversation.