I have tested this which works as expected. To add some more explanation, I'm trying this to save the whole option as TStringList. As you can see in the following codes, one CodeOption corresponds to an Input of HTML Dom. I'd like to define HTML inputs programmatically, and users are able to edit the attributes of the inputs in my Lazarus program, using TIPropertyGrid.
The content is saved as text, TCodeOptions.Text, in DB. I'm trying to reduce my own code writings.
type
TInputTypes = (itText, itPassWord, itRadio, itCheckbox, itHidden, itTel,
itNumber, itUrl, itEmail, itRange, itDate, itMonth, itWeek);
TCodeOptions = class (TStringList)
private
function getInputType: TInputTypes;
function getIntegerOption(AIndex: Integer): integer;
function getRequired: Boolean;
function getStringOption(AIndex: Integer): string;
procedure setInputType(AValue: TInputTypes);
procedure setIntegerOption(AIndex: Integer; AValue: integer);
procedure setRequired(AValue: Boolean);
procedure setStringOption(AIndex: Integer; AValue: string);
published
// HTML input attributes
property InputType: TInputTypes read getInputType write setInputType;
property Pattern: string index 2 read getStringOption write setStringOption;
property PlaceHolder: string index 3 read getStringOption write setStringOption;
property Title: string index 4 read getStringOption write setStringOption;
property Required: Boolean read getRequired write setRequired;
property MinLength: integer index 1 read getIntegerOption write setIntegerOption;
property Min: integer index 11 read getIntegerOption write setIntegerOption;
property Max: integer index 12 read getIntegerOption write setIntegerOption;
property Step: integer index 13 read getIntegerOption write setIntegerOption;
// Custom options
property PreText: string index 101 read getStringOption write setStringOption;
property PostText: string index 102 read getStringOption write setStringOption;
end;