Sign in Join
Wiki copytemporary

TTICheckListBox

For editing set of enumerated types. Let's assume that we have following definitions.

pascal
   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.

pascal
      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,

pascal
      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:

text
    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

pascal
      Nov in FMonths

will return true.


From the Free Pascal wiki, page "TTICheckListBox", as it stood on 2022-04-02 after a change by Alextpp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 2, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.