Board index » delphi » Accessing Checkbox in a GroupBox

Accessing Checkbox in a GroupBox

How do I perform a loop to access Checkboxes in a GroupBox?
I tried it with  ComponentIndex but did not find the right way.
Please give me some hint
Roman
 

Re:Accessing Checkbox in a GroupBox


Quote
gmx wrote:
> How do I perform a loop to access Checkboxes in a GroupBox?
> I tried it with  ComponentIndex but did not find the right way.
> Please give me some hint
> Roman

try something like
    with GroupBox do
    for i:=0 to controlCount-1 do
    if Controls[i] is TCheckBox then ...

Re:Accessing Checkbox in a GroupBox


Could you help me further on how to assign the Checkbox  in the loop so I
can
access CheckboxXY.checked ?
Is this  something like:

VAR    CB      : TCheckBox;

 loop...  with GroupBox ...

    CB := ????
    Signed  := CB.checked

How do I assign CB to the TCheckbox witch is pointet to by Controls[i]  ??

teknokr@t schrieb in Nachricht <378C0538.C00AA...@mindless.com>...

Quote

>gmx wrote:

>> How do I perform a loop to access Checkboxes in a GroupBox?
>> I tried it with  ComponentIndex but did not find the right way.
>> Please give me some hint
>> Roman

>try something like
>    with GroupBox do
>    for i:=0 to controlCount-1 do
>    if Controls[i] is TCheckBox then ...

Re:Accessing Checkbox in a GroupBox


<<gmx:
Could you help me further on how to assign the Checkbox  in the loop so I
can
access CheckboxXY.checked ?
Is this  something like:

VAR    CB      : TCheckBox;

loop...  with GroupBox ...

    CB := ????
    Signed  := CB.checked

How do I assign CB to the TCheckbox witch is pointet to by Controls[i]  ??

Quote

>gmx wrote:

>> How do I perform a loop to access Checkboxes in a GroupBox?
>> I tried it with  ComponentIndex but did not find the right way.
>> Please give me some hint
>> Roman

>try something like
>    with GroupBox do
>    for i:=0 to controlCount-1 do
>    if Controls[i] is TCheckBox then ...

if you assume that the checkboxes are created in the right order, do:

   with GroupBox do
     for i:=0 to ControlCount-1 do
        if Controls[i] is TCheckBox then
          CB:=TCheckBox(Controls[i]);

--

Bjoerge

Re:Accessing Checkbox in a GroupBox


I use this code:

/Clear choises in checkboxes.
for i := 0 to Pred(GroupBox1.ControlCount) do
     begin
     if GroupBox1.Controls[i] is TCheckBox then
        with GroupBox1.Controls[i] as TCheckBox do
             Checked := False;
     end;

I hope this helps

jrlee

Other Threads