You can also use the Form.components property and
iterate over them with the 
    If Form1.components is TCheckbox Then dosomething

   condition to only modify the checkbox components. 

You could use a further condition like 

    If Form1.components.parent = Groupbox1

  to further delineate groups of checkboxes (or any
component).

for example:

For i := 0 to Form1.componentcount-1 do
 If Form1.components[i] is TCheckbox Then 
   If (form1.components[i] as Tcheckbox).parent =
Groupbox1 Then
     (form1.components[i] as TCheckbox).Checked :=
false;

  Be careful to specify the owner component (IE.
form1) since all components have the components[]
property. 

Dave


--- Rob Kennedy <[EMAIL PROTECTED]> wrote:

> So Ing wrote:
> > can I have delphi components / object which name
> is number(integer) ? like
> > a VB?
> 
> VB doesn't allow that. What it lets you do is assign
> a group of components
> the same name, differentiated by a number. It
> implicitly creates an array
> of components by that name, and the numbers are the
> components' indices in
> the array.
> 
> Delphi components must all have different names, and
> they are not allowed
> to contain punctuation.
> 
> Delphi allows you to declare whatever arrays you
> want. If you want an
> array of TEdit controls, then declare one in your
> form's private section:
> 
> type
>   TSoIngForm = class(TForm)
>   private
>     FGradeEdits: array of TEdit;
>   end;
> 
> Make the array whatever size you need, and then fill
> it with references to
> whatever controls you want. Those controls don't
> need to have the same
> base names. You could have your form's OK, cancel,
> and help buttons in an
> array like this:
> 
> SetLength(FormButtons, 3);
> FormButtons[0] := OKButton;
> FormButtons[1] := CancelButton;
> FormButtons[2] := HelpButton;
> 
> >   or I have to make another new class?
> >   or there is another way to trick this?
> 
> A trick to use is the FindComponent function. You
> give it a name, and it
> will return a reference to the component with that
> name. Check the help
> for details.
> 
> If you had a group of components with names like
> GradeEdit0, GradeEdit1,
> GradeEdit2, etc., then you could get a reference to
> control N with the
> exxpression Self.FindComponent('GradeEdit' +
> IntToStr(N)). Its return type
> is TComponent, so you'll need to type-cast it to
> whatever type you need.
> 
> Use that in combination with the array you declare
> to populate the entire
> array with a loop.
> 
> >   actually I make a school project that use a lot
> of checkbox
> >   and it is very tiresome to fill each checkbox
> manually
> >   so if I have a component name that using a
> number then I can use an
> > iteracy to fill all the checkboxes
> 
> Once you have you array, you can iterate over it
> just as you would any
> other array.
> 
> -- 
> Rob
> 
> 
> 



                
__________________________________________ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/I258zB/QnQLAA/TtwFAA/i7folB/TM
--------------------------------------------------------------------~-> 

-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to