Iterate through all controls of a form

Hi Christian
First, you could look at the SysSetupForm form and Class. This form and
class iterates through a form and displays its setup. It is quite advanced so
if you want a simpler but limited solution you could follow the approch that
I have sketched below

1. In you run() method, loop through the controls of your form. This can be
done using the line below
for(i=1 ; i<=element.form().design().controlCount();i++)
{
control = element.form().design().controlNum(i);
element.printControls(control); //you must implement this yourself

}
2. Pass each FormBuildcontrol to a new method printControls(), in the loop.
You can place it in a class or in the form.

3. The printControl() method will have to call itself recursivly, if the
FormBuildControl passed is a container. The code below migth give you an idea
of how the function body could look :

for(i=1 ; i <= _control.controlCount();i++)
{
control = _control.controlNum(i);

if(control.isContainer())//call recursively
{
this.printControls(control);
}
else // the lowest level of the container is reached
{

switch(control.handle())
{
case classnum(FormBuildStringControl):

formStringControl = control;
info(strfmt("formStringControl name %1 Datafield %2",
formStringControl.name(),formStringControl.dataFie ld() ));
break;
//include cases for the other controls
}
}

Hopefully this gives you some inspiration to start.

Have fun!
Lennart Conrad
Microsoft Business Solutions
This posting is provided "AS IS" with no warranties, and confers no rights.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.