Difference between revisions of "TTICheckListBox"
From Lazarus wiki
Jump to navigationJump to search (add syntax hilite blocks) |
|||
Line 1: | Line 1: | ||
For editing set of enumerated types. Let's assume that we have following definitions. | For editing set of enumerated types. Let's assume that we have following definitions. | ||
− | + | <syntaxhighlight lang="Pascal"> | |
type | type | ||
TMonth = (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec); | TMonth = (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec); | ||
Line 11: | Line 11: | ||
property Months: TMonths read FMonths write FMonths; | property Months: TMonths read FMonths write FMonths; | ||
end; | end; | ||
− | + | </syntaxhighlight> | |
Properties of TTICheckListBox.Link can be assigned as following way. | Properties of TTICheckListBox.Link can be assigned as following way. | ||
+ | <syntaxhighlight lang="Pascal"> | ||
with TICheckListBox1.LInk do begin | with TICheckListBox1.LInk do begin | ||
TIObject:= Form1; | TIObject:= Form1; | ||
TIPropertyName := 'Months'; | TIPropertyName := 'Months'; | ||
end; | end; | ||
+ | </syntaxhighlight> | ||
Assigning TTICheckListBox.Link.AliasValues will change displayed string of items. So, if defined in following way, | Assigning TTICheckListBox.Link.AliasValues will change displayed string of items. So, if defined in following way, | ||
+ | <syntaxhighlight lang="Pascal"> | ||
with TICheckListBox1.LInk do begin | with TICheckListBox1.LInk do begin | ||
with AliasValues do begin | with AliasValues do begin | ||
Line 35: | Line 38: | ||
TIPropertyName := 'Months'; | TIPropertyName := 'Months'; | ||
end; | end; | ||
+ | </syntaxhighlight> | ||
The checklist items will be displayed in following way and order: | The checklist items will be displayed in following way and order: | ||
Line 52: | Line 56: | ||
The "checked" months will be correctly stored in the FMonths field of Form1. That is, if you ckeck November, then | The "checked" months will be correctly stored in the FMonths field of Form1. That is, if you ckeck November, then | ||
− | + | <syntaxhighlight lang="Pascal"> | |
Nov in FMonths | Nov in FMonths | ||
+ | </syntaxhighlight> | ||
will return true. | will return true. |
Latest revision as of 17:02, 2 April 2022
For editing set of enumerated types. Let's assume that we have following definitions.
type
TMonth = (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec);
TMonths = set of TMonth;
//
TForm1 = class(TForm)
private
FMonths: TMonths;
published
property Months: TMonths read FMonths write FMonths;
end;
Properties of TTICheckListBox.Link can be assigned as following way.
with TICheckListBox1.LInk do begin
TIObject:= Form1;
TIPropertyName := 'Months';
end;
Assigning TTICheckListBox.Link.AliasValues will change displayed string of items. So, if defined in following way,
with TICheckListBox1.LInk do begin
with AliasValues do begin
Clear;
Add('Jan=January');
Add('Feb=February');
Add('Mar=March');
Add('Apr=April');
Add('Nov=November');
Add('Dec=December');
end;
TIObject:= Form1;
TIPropertyName := 'Months';
end;
The checklist items will be displayed in following way and order:
January February March April November December May Jun Jul Aug Sep Oct
The "checked" months will be correctly stored in the FMonths field of Form1. That is, if you ckeck November, then
Nov in FMonths
will return true.