Difference between revisions of "TTICheckListBox"
From Free Pascal wiki
Jump to navigationJump to searchLine 1: | Line 1: | ||
− | For editing set of enumerated types. Let's assume that | + | For editing set of enumerated types. Let's assume that we have following definitions. |
type | type | ||
Line 13: | Line 13: | ||
− | + | Properties of TTICheckListBox.Link can be assigned as following way. | |
with TICheckListBox1.LInk do begin | with TICheckListBox1.LInk do begin | ||
Line 19: | Line 19: | ||
TIPropertyName := 'Months'; | TIPropertyName := 'Months'; | ||
end; | 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. |
Revision as of 11:08, 1 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.