TCheckListBox/fi: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: TCheckListBox/fi
| Old | New | Line | |
|---|---|---|---|
| 1 | + | **TCheckListBox**  on komponentti joka näyttää tarvittaessa vieritettävän luettelon valintaruuduista, joista käyttäjä voi tehdä useita valintoja. Se löytyy [[Additional tab/fi|Additional]] -välilehdeltä [[Component Palette/fi|komponenttipaletilta]]. | |
| 2 | + | ||
| 3 | + | <figure> | |
| 4 | + | <img src="CheckListBoxDemo.png" title="CheckListBoxDemo.png" /> | |
| 5 | + | <figcaption>CheckListBoxDemo.png</figcaption> | |
| 6 | + | </figure> | |
| 7 | + | ||
| 8 | + | ## Käyttö | |
| 9 | + | ||
| 10 | + | Ajattele, että TCheckListBox on kaksiosainen, [[TListBox/fi|TListBox]]:n merkkijonot ovat oikealla ja vasemmalla valintaruudut. Merkkijonot ovat tyypillisesti kuvauksia siitä, mitä käyttäjä valitsee, jos he klikkaavat valintaruutua. Merkkijonot voidaan ladata yksittäin käyttäen (esim.) - | |
| 11 | + | ||
| 12 | + | ``` pascal | |
| 13 | + | CheckListBox1.AddItem('Line One', Nil); | |
| 14 | + | CheckListBox1.AddItem('Line Two', Nil); | |
| 15 | + | ``` | |
| 16 | + | ||
| 17 | + | Tai siihen voidaan liittää muualla tehty merkkijonoluettelo - | |
| 18 | + | ||
| 19 | + | ``` pascal | |
| 20 | + | CheckListBox1.Items.Assign(MyStringList); | |
| 21 | + | ``` | |
| 22 | + | ||
| 23 | + | Hyvä idea on laittaa valintaruudut tiettyyn tilaan - | |
| 24 | + | ||
| 25 | + | ``` pascal | |
| 26 | + | for I := 0 to CheckListBox1.Count-1 do | |
| 27 | + | CheckListBox1.Checked[I] := False; | |
| 28 | + | ``` | |
| 29 | + | ||
| 30 | + | TCheckListBox antaa käyttäjälle mahdollisuuden valita niin monta valintaruutua kuin he haluavat. Käyttämällä OnItemClick-tapahtumaa voidaan sillä pakottaa niin että voidaan valita enintään yksi | |
| 31 | + | ||
| 32 | + | ``` pascal | |
| 33 | + | procedure TNoteBookPick.CheckListBox1ItemClick(Sender: TObject; Index: integer); | |
| 34 | + | var | |
| 35 | + | I : integer; | |
| 36 | + | begin | |
| 37 | + | if (Sender as TCheckListBox).Checked[Index] then begin | |
| 38 | + | for I := 0 to CheckListBox1.Count -1 do | |
| 39 | + | CheckListBox1.Checked[I] := False; | |
| 40 | + | CheckListBox1.Checked[Index] := True; | |
| 41 | + | end; | |
| 42 | + | end; | |
| 43 | + | ``` | |
| 44 | + | ||
| 45 | + | Valintaruutujen lukeminen kun (esim.) sovelluksen käyttäjä on vastannut | |
| 46 | + | ||
| 47 | + | ``` pascal | |
| 48 | + | for I := 0 to CheckListBox1.Count -1 do | |
| 49 | + | if CheckListBox1.Checked[I] then DebugLn('Checked Item ' + CheckListBox1.Items[I]); | |
| 50 | + | ``` | |
| 51 | + | ||
| 52 | + | ## Katso myös | |
| 53 | + | ||
| 54 | + | - [[doc:lcl/checklst/tchecklistbox.html|TCheckListBox doc]] | |
| 55 | + | - [[TCheckBox]] | |
| 56 | + | - [[TListBox]] | |
| 57 | + | ||
| 58 | + | --- | |
| 59 | + | *From the Free Pascal wiki, page "TCheckListBox/fi", as it stood on 2018-01-31 after a change by Djzepi, 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](/wiki-contact).* |
