[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.axapta.programming

How can i get reference of any controls of Form at class level

Manish Verma

11/24/2005 10:31:00 AM

Dear All

How can i get reference of any controls of Form at class level.

For example--: On standard Axapta Application SalesTable Form having the
post button on the SalesTable Form Header i can get the absolute path of this
control through the right-click to the control it self and go to
Add-Ins-Copy-Entire Path through this i can got following absolute path:

\Forms\SalesTable\Designs\Design\[Group:Table]\[ButtonGroup:ButtonsHeader]\[MenuButton:ButtonHeaderUpdate]

Axapta application programming having any standard method through which we
can get reference of sepecific path.

Manish Verma


5 Answers

Luegisdorf

12/1/2005 10:36:00 AM

0

Hi Manish

Do you need a handle to the a specific control on a form?

If yes, that's easy:

// direct access with name
FormButtonControl formControl;
;
formControl = formRun.design.controlName('myButtonControl');
formControl.visible(false); // modify a property


// or loop all controls
FormControl formControl;


getAllControlsInside(Object _obj)
{
int i;
;
if (classIdGet(obj) == classnum(FormDesign) || // only container
controls, may be there are some more ...
classIdGet(obj) == classnum(FormGroupControl) ||
classIdGet(obj) == classnum(FormButtonControl) ||
classIdGet(obj) == classnum(FormTabControl) ||
classIdGet(obj) == classnum(FormTabPageControl))
{

for (i = 1; i <= formRun.design().controlCount(); i++)
{
formControl = formRun.design.controlName('myButtonControl');
info(formControl.name());
getAllControlsInside(formControl);
}
}
}
;
getAllControlsInside(formRun.design());


If I was going wrong, please let me know what else your desire is ;-)
Best regards
Patrick

PS: the code snippet was written direct in this forum so it could contain
some little bugs.

"Manish Verma" wrote:

> Dear All
>
> How can i get reference of any controls of Form at class level.
>
> For example--: On standard Axapta Application SalesTable Form having the
> post button on the SalesTable Form Header i can get the absolute path of this
> control through the right-click to the control it self and go to
> Add-Ins-Copy-Entire Path through this i can got following absolute path:
>
> \Forms\SalesTable\Designs\Design\[Group:Table]\[ButtonGroup:ButtonsHeader]\[MenuButton:ButtonHeaderUpdate]
>
> Axapta application programming having any standard method through which we
> can get reference of sepecific path.
>
> Manish Verma
>
>

Mike Frank

12/1/2005 1:34:00 PM

0

Or a bit more generic

public static void listControls(FormRun formRun)
{
int level;

boolean hasMethod(Object obj, identifierName methodName)
{
return new SysDictClass(classidget(obj)).isMethodActual(methodName);
}

str objectType(Object obj)
{
return new SysDictClass(classidget(obj)).name();
}

void GetChildControls(Object control)
{
int ctrlNum;
FormControl childControl;
Object childControlObj; // for Axapta "casting by assigning"
;
// those methods should be on every container control, but we want to be sure
// (there should actually be a father class (or better an interface) for all of them,
// exposing those methods)
if (hasMethod(control, 'controlCount') && hasMethod(control, 'controlNum'))
{
level++;
for (ctrlNum = 1; ctrlNum <= control.controlCount(); ctrlNum++)
{
childControl = control.controlNum(ctrlNum);
info(strfmt('%1%2 (%3)', strrep(' ', level * 3), childControl.name(),
objectType(childControl)));

childControlObj = childControl;
if (hasMethod(childControl, 'isContainer') && childControlObj.isContainer())
{
GetChildControls(childControl);
}
}
level--;
}
}
;
info(formRun.name());
GetChildControls(formRun.design());
}

You can call this from inside a form passing element or like this

Args args = new Args(formstr(InventTable));
FormRun formRun = new ClassFactory().formRunClass(args);
;
formRun.init();
CbsTools::listControls(formRun);

Manish Verma

12/7/2005 7:33:00 AM

0

hi Luegisdorf !

Thanx Luegisdorf to sending this ,but this code is no working on
class level.
I want to access any specific control on any method of class but this code
is not working on class level.

I am writting following code on class method:

void AccesFormControl(FormRun formRun)
{
FormButtonControl formControl;
;

formControl = formRun.design().controlName("ButtonToggelSimple");
formControl.visible(false);

}

and i'm call this method from the run method of "Purch table" like this:

void run()
{
Args args = new Args(formstr(PurchTable));
FormRun formRun = new ClassFactory().formRunClass(args);
;
super();

MenuButtonApprover.enabled(false); // USR-Modification on 08 Nov 2005 by
E-297

if (!advanced)
TabHeader.tab(2);
else
TabHeader.tab(1);

eis297_Approve.AccesFormControl(formrun); // method called here


}
But these code sequence flashing the error messge "Formdesign object not
initilized" .

Can u do some thing in situation?

If u have solution for this problem plz revert me back as soon as possible.



Thanks & regards
Manish Verma
ph-919871438143
e-mail: manishv@euroinfosys.com



"Luegisdorf" wrote:

> Hi Manish
> hanx
> Do you need a handle to the a specific control on a form?
>
> If yes, that's easy:
>
> // direct access with name
> FormButtonControl formControl;
> ;
> formControl = formRun.design.controlName('myButtonControl');
> formControl.visible(false); // modify a property
>
>
> // or loop all controls
> FormControl formControl;
>
>
> getAllControlsInside(Object _obj)
> {
> int i;
> ;
> if (classIdGet(obj) == classnum(FormDesign) || // only container
> controls, may be there are some more ...
> classIdGet(obj) == classnum(FormGroupControl) ||
> classIdGet(obj) == classnum(FormButtonControl) ||
> classIdGet(obj) == classnum(FormTabControl) ||
> classIdGet(obj) == classnum(FormTabPageControl))
> {
>
> for (i = 1; i <= formRun.design().controlCount(); i++)
> {
> formControl = formRun.design.controlName('myButtonControl');
> info(formControl.name());
> getAllControlsInside(formControl);
> }
> }
> }
> ;
> getAllControlsInside(formRun.design());
>
>
> If I was going wrong, please let me know what else your desire is ;-)
> Best regards
> Patrick
>
> PS: the code snippet was written direct in this forum so it could contain
> some little bugs.
>
> "Manish Verma" wrote:
>
> > Dear All
> >
> > How can i get reference of any controls of Form at class level.
> >
> > For example--: On standard Axapta Application SalesTable Form having the
> > post button on the SalesTable Form Header i can get the absolute path of this
> > control through the right-click to the control it self and go to
> > Add-Ins-Copy-Entire Path through this i can got following absolute path:
> >
> > \Forms\SalesTable\Designs\Design\[Group:Table]\[ButtonGroup:ButtonsHeader]\[MenuButton:ButtonHeaderUpdate]
> >
> > Axapta application programming having any standard method through which we
> > can get reference of sepecific path.
> >
> > Manish Verma
> >
> >

Mike Frank

12/7/2005 3:21:00 PM

0

Hi E-297,

formRun.design.controlName('ControlName') is a correct way of accesing a form control. This has
nothing to do with class level (whatever you mean by this).
The FormDesign is not initialized in your code because you did not call init on the FormRun object
you were creating. Anyway if you want to change controls on the PurchTable form, from which you are
calling your method, you should pass this FormRun to your method through the element keyword
(eis297_Approve.AccesFormControl(element))instead of creating a new FormRun.

Manish Verma

12/8/2005 5:37:00 AM

0

Hi Mike Frank !

Thank you so much to giving me quick responses for my queries. Now
i'm able to access form controls any where through the way give by you.

please give me your e-mail id so that i can touch with you.

with thanks & regards
Manish Verma
ph-919871438143
E-mail : manishv@euroinfosys.com


"Mike Frank" wrote:

> Hi E-297,
>
> formRun.design.controlName('ControlName') is a correct way of accesing a form control. This has
> nothing to do with class level (whatever you mean by this).
> The FormDesign is not initialized in your code because you did not call init on the FormRun object
> you were creating. Anyway if you want to change controls on the PurchTable form, from which you are
> calling your method, you should pass this FormRun to your method through the element keyword
> (eis297_Approve.AccesFormControl(element))instead of creating a new FormRun.
>