Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 7 Monaten, 2 Wochen
Letzter Beitrag:
vor 7 Monaten, 1 Woche
Beteiligte Autoren:
Bart VDE, Fabrice Harari

[WD17] Control template in looper

Startbeitrag von Bart VDE am 15.10.2017 16:49


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 ?



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

von Fabrice Harari - am 16.10.2017 13:23
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,

von Bart VDE - am 16.10.2017 17:15
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

von Fabrice Harari - am 16.10.2017 22:45
Ok Fabrice, fair enough.
Thanks for your reply.


von Bart VDE - am 17.10.2017 13:14
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.