Join us today!

How to Create dynam...
 
Notifications
Clear all

How to Create dynamicly a user control inside another user control

8 Posts
3 Users
3 Reactions
745 Views
Posts: 9
Topic starter
(@tiago29a)
Active Member
Joined: 2 years ago

Hey guys

 

I have an usercontrol that has all the controls of my motor, and now I made an usercontrol to control the configuration of the motor. I want to create it dynamic, so the hole application runs better on the IHM. I will share how I'm doing the code and explain line by line.

novoPopUp = TcHmi.ControlFactory.createEx( // create the configuration usercontrol
        'TcHmi.Controls.System.TcHmiUserControlHost', //says its a usercontrol type
         nome +'.Config',// the name of it
        {
            'data-tchmi-target-user-control':  
            "UserControl/Popup/Motor/ucPopUpMotoresConfig.usercontrol",
            'data-tchmi-top': 15,
            'data-tchmi-left': 30,
            'data-tchmi-width': 710,
            'data-tchmi-height': 420
        }
        ,objetoTC //  the father object
	);
	
      
	var desktop = TcHmi.Controls.get('Desktop');   // show in the desktop

 

With this code, I can create a new usercontrol and show it. My problem now is that I want it to be inside the already created usercontrol (the objetoTC one).

Does anyone know how to do it?

Or even if it's possible to do it?

 

 

 

 

Reply
7 Replies
runtimevictor
Posts: 156
(@runtimevictor)
Estimable Member
Joined: 2 years ago

Hello, 

if you can send some images so that it is understood...

Reply
4 Replies
(@tiago29a)
Joined: 2 years ago

Active Member
Posts: 9

@runtimevictor 

Hey

so the first image is the usercontrol of the control of the motor, and when i click on the gear in the right corner i opens the configuration. The thing is, its opens outside the control usercontrol (Second image) and i want it to opens inside of it

PopupNormal
config instanciada

 

 sorry if I was not so clear, I was melting my mind trying to figure this out. 😀 

Reply
runtimevictor
(@runtimevictor)
Joined: 2 years ago

Estimable Member
Posts: 156

@tiago29a ,

https://automacaoweb.wordpress.com/2022/03/16/tf2000-popup/

Reply
(@tiago29a)
Joined: 2 years ago

Active Member
Posts: 9

@runtimevictor Sorry I don't see where this tutorial would be helpful, it never instantiates an object dynamically.

Reply
runtimevictor
(@runtimevictor)
Joined: 2 years ago

Estimable Member
Posts: 156

@tiago29a ,

Hello, it was in case you wanted to try another way of doing it... 😎 

Reply
Posts: 9
Topic starter
(@tiago29a)
Active Member
Joined: 2 years ago

Heyyy

 

just for future reference, this is the code that work.

//Instancia o popup de config dentro do pai
	var Pai = TcHmi.Controls.get(nome + '.ucPopUpMotores');
	var novoPopUp = TcHmi.ControlFactory.createEx(
        'TcHmi.Controls.System.TcHmiUserControlHost',
         nome +'.Config',
        {
            'data-tchmi-target-user-control': "UserControl/Popup/Motor/ucPopUpMotoresConfig.usercontrol",
            'data-tchmi-top': 30,
            'data-tchmi-left': 10,
            'data-tchmi-width': 710,
            'data-tchmi-height': 420
        }
        ,Pai
	);
	
	novoPopUp.setZindex(5000);
	
	if (Pai && novoPopUp) {
	    Pai.__addChild(novoPopUp);
	}
Reply
Posts: 9
(@unchained)
Active Member
Joined: 2 years ago

Could you also share the code to close that pop up?

Reply
Share: