PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 2024 → [WD17] Control template in looper
[WD17] Control template in looper
Iniciado por Bart VDE, out., 15 2017 6:49 PM - 4 respostas
Publicado em outubro, 15 2017 - 6:49 PM
Hello,

I have a control template with 3 edits: edtName, edtAddress, edtCity

I have put this control template in a looper.

Now I want to control the visibility of those edits.

In my looper I have just one control for which i can make an attribute, i.e. my control template itself. So it's not possible to make an attribute for one of the edits in my control template for setting the visibility.

How can I access the edit fields in this control template and set the visible property ?

Code like this does not work:
Idx = looperaddline(MyLooper)
MyLooper[Idx].attMyControlTemplate.edtName..visible = False does not work

Anyone any suggestions ?

Thx,
Bart
Publicado em outubro, 16 2017 - 3:23 PM
Hi Bart

why would you want to use a control template in looper? Just paste each control that is part of the template in it, and they will be repeated on each line of the looper, and easily usable.

What could you possibly gain by trying to do that?

Best regards
Publicado em outubro, 16 2017 - 7:15 PM
Hi Fabrice,

Why I want to do that? Because Control templates exists in WinDev.

There is also a lot of code in the onChange and onExit events in these edits, so it seems a nice solution to me that UI and code behind can be on one place and doesn't need to be copy and paste over and over again. Just inherit UI and the code and that's it.

Of course, I could make global procedures for handling these events, but this is ridiculous because the code is thight bound to these controls and don't need to be global at all.

Control templates are a nice feature but unfortunatly is once again half baked it seems. Of course I can copy each control in the looper but why the hell do they make control templates? Doesn't make sense to me.

Kind regards,
Bart
Publicado em outubro, 17 2017 - 12:45 AM
Hi Bart,

they are making a control template in order to do everything you describe in all situations that are EQUAL.

However, a looper is not the same as a window. The same control is/are repeated many times (once for each line) and the CODE needed to access the each control is completely different than with controls on a page (attributes, line number, etc). Therefore, any local code to a control will NOT work in a looper (as the syntax to access it is different, and as what you can effectively do with it is limited compared to a control in a window)

So, a looper is not the same, will not behave the same, and does not have the same rules than a window. Therefore, the control template made for a window will not work.

Best regards
Publicado em outubro, 17 2017 - 3:14 PM
Ok Fabrice, fair enough.
Thanks for your reply.

Regards,
Bart