Sign in Join
Wiki copytemporary

TCheckListBox/fi: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11**TCheckListBox** ![](/wiki-images/9/98/Tchecklistbox.png) 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]].
22
3-<figure>
4-<img src="CheckListBoxDemo.png" title="CheckListBoxDemo.png" />
5-<figcaption>CheckListBoxDemo.png</figcaption>
6-</figure>
3+![](/wiki-images/d/d6/CheckListBoxDemo.png)
74
85## Käyttö
96
107Ajattele, 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.) -
118
129``` pascal
1310CheckListBox1.AddItem('Line One', Nil);
1411CheckListBox1.AddItem('Line Two', Nil);
1512```
1613
1714Tai siihen voidaan liittää muualla tehty merkkijonoluettelo -
1815
1916``` pascal
2017CheckListBox1.Items.Assign(MyStringList);
2118```
2219
2320Hyvä idea on laittaa valintaruudut tiettyyn tilaan -
2421
2522``` pascal
2623 for I := 0 to CheckListBox1.Count-1 do
2724 CheckListBox1.Checked[I] := False;
2825```
2926
3027TCheckListBox 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
3128
3229``` pascal
3330procedure TNoteBookPick.CheckListBox1ItemClick(Sender: TObject; Index: integer);
3431var
3532 I : integer;
3633begin
3734 if (Sender as TCheckListBox).Checked[Index] then begin
3835 for I := 0 to CheckListBox1.Count -1 do
3936 CheckListBox1.Checked[I] := False;
4037 CheckListBox1.Checked[Index] := True;
4138 end;
4239end;
4340```
4441
4542Valintaruutujen lukeminen kun (esim.) sovelluksen käyttäjä on vastannut
4643
4744``` pascal
4845 for I := 0 to CheckListBox1.Count -1 do
4946 if CheckListBox1.Checked[I] then DebugLn('Checked Item ' + CheckListBox1.Items[I]);
5047```
5148
5249## Katso myös
5350
5451- [[doc:lcl/checklst/tchecklistbox.html|TCheckListBox doc]]
5552- [[TCheckBox]]
5653- [[TListBox]]
5754
5855---
5956*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).*

Back to history