158 views
in GUI Development by
Hello,

I want to pass some parameters when calling the constructor new for a component, so those parameters get used in the initialization of the component, where those parameters are properties of the component

Example :

new Application::ReceiptProgam ( numOfProgram,NameOfProgram) ;

Creates the object ReceiptProgam with properties itialized with values numOfProgram,NameOfProgram;

1 Answer

+1 vote
by
 
Best answer

Hello Riccardo,

passing arguments in Init() method is not possible. The recommended approach is to implement a dedicated initialization method, which after performing the initialization returns this. For example:

Then to create a new object of the class and initialize it with the desired arguments, you perform following or similar code:

var Application::Data data = (new Application::Data).Initialize( 1, 2 );

I hope it helps you further.

Best regards

Paul Banach

by

i want to do this in an Array but i get this error

 

edit: i have to put Application::ReceiptList in the return of the function

by

Hello Riccardo,

edit: i have to put Application::ReceiptList in the return of the function

yes, the return type of such 'initilaization' method has to correspond to the class of the object. Does it mean, you solved the issue?

Best regards

Paul

by
Yes, thanks that was the intent.

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...