How do I correctly implement a Set in a class as a property?
delphi, delphi-xe
Solution
From TLama's comment I looked at the Delphi source for Anchors and came up with the solution here:
TDelphiIDECompatibilityKind = (
Delphi1,
Delphi2,
Delphi3);
TDelphiIDECompatibility = set of TDelphiIDECompatibilityKind;
And the class:
private
FIDECompatibility: TDelphiIDECompatibility;
public
constructor Create;
destructor Destroy; override;
property IDECompatibility: TDelphiIDECompatibility read
FIDECompatibility write FIDECompatibility;
end;
Problem
Suppose I have the following as an example: ``` TDelphiIDECompatibility = ( Delphi1, Delphi2, Delphi3); ``` From a class, how could I implement the above correctly as a property? The idea is that in my component I want to have a field that will allow you to select True or False for certain elements in a Set. I tried to declare like this without much luck: ``` TMyClass = class private FIDECompatibility: Set of TDelphiIDECompatibility; public constructor Create; destructor Destroy; override; property IDECompatibility: TDelphiIDECompatibility read FIDECompatibility write FIDECompatibility; end; ``` The error message been: Incompatible types: 'TDelphiIDECompatibility' and 'Set' The quick way I know is to just declare them as regular booleans, like so: ``` private FDelphi1Compatible: Boolean; FDelphi2Compatible: Boolean; FDelphi3Compatible: Boolean; public constructor Create; destructor Destroy; override; property Delphi1Compatible: Boolean read FDelphi1Compatible write FDelphi1Compatible; end; ``` But I don't really like having it like that when I can have them defined in a Set/Enumeration? What should I be doing to declare it properly instead? Thank you.