On Friday 13 January 2006 00:58, Emile Schwarz wrote:
> [EMAIL PROTECTED] wrote:
> > Subject: How do I loop thru the controls
> > From: johnf <[EMAIL PROTECTED]>
> > Date: Wed, 11 Jan 2006 23:02:49 -0800
> >
> > Hi,
> >
> > How can I loop through all the editfields within a window?  I want to set
> > all the controls to enable = False.  I do have tabs and a few other
> > controls.  I found window.controlcount and I'm sure that will help but I
> > don't know what to do next.
>
> The documentation is your best friend. If you looked at the User's Guide,
> pages 433 and 434 (or make a search in the pdf for say ControlCount) you
> will get it.
>
>
> <quote>
> Here is an example that uses a For loop to cycle through all the controls
> in a window to test whether each control is an EditField. If it is, it
> casts the control, gets its name  and the values of its Text and DataField
> properties, and assigns the contents of the EditField to the field in a
> database table named fieldname.
> </quote>
>
>
> Nota: do not think that you will find explanations or examples for each of
> your questions, but please, take the habbit to search there first.
>
>
> Another place to look for (note to self: this advice is good for me too) is
> the examples archive that you can download from REAL Software site (or get
> in the CD if you buy it).
>
> > Thanks guys!  I did not realize the Window1.Control() was an array of the
> > controls.  But where or better how did you guys figure that out.  I just
> > checked the lang ref and the only thing for control is "control class". 
> > The doc does not refer to any type of an array.  Maybe it is in the
> > window def. Thanks again guys.
>
> You forget the User's Guide (and did you know that the Language Reference
> exists in pdf too ?).
>
>
>
>
> What is my _other_ addition to the answers you already get ?
>
> Suppose that you _now_ want to enable one EditField - say EFLog for
> example. How do you do that ?
>
> Simple. Take Joe's example and modify it a bit:
>
>
>    Dim i  As Integer
>    Dim EF As EditField
>
>    // Loop thru the Window controls
>    For i = 0 To ControlCount-1 // 0-based
>      // Do something only if the Control is of type EditField
>      If Control(i) IsA EditField Then
>        // Cast the Control
>        EF = EditField(Control(i))
>        // Search the EFLog EditField
>        If EF.Name = "EFLog" Then
>          // I found it !
>          EF.Enabled = True
>        End If
>      End If
>    Next
>
>
> NOTA: the provided code have been tested ! (and It Works®)
>
>
> Question: You may ask "What if I want to act on other properties of this
> EditField ?
>
> Answer: Look at the {If EF.Name = "EFLog" Then} ... So, use
> EF.<PRopertyName> et voilĂ ...
>
>
> BTW: Pages 171, 172 and 173 are identical (same contents, excepted for the
> page #), REALbasic 2005 version.
>
> HTH,
>
> Emile
>
>
>
> PS: you can search ListBox - and other controls - in the same way:
>
> If Control(i) IsA ListBox Then
>
> or
>
> If Control(i) IsA StaticText Then
>
> Isn't it nice ?

Wow thanks very much!  

I keep forgetting about casting - but last night I dreamed about it.  

Anyway thank again
John
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to