[Gambas-user] How to duplicate Ctrls with preferences at runtime (2)

Yahoo olivier.cruilles at yahoo.fr
Thu Mar 26 14:01:41 CET 2020


Hello,

I’m not sure to understand exactly your request, but I think you could use Form embedded, as like you don’t want to use, but adding Properties at the Form ‘Template’, so it will really easy to access to the various children inside.

To identify each Form embedded included into your main Form, add a Property for that, like IdForm for example.

Next you could use an Array of your embedded Form to manage all created Forms like:


1-  Design your Form themplate
2-  Create an array to manage those Forms

For example if your Form template is name ‘MyFormTemplate'


Public MyArrayForm as  MyFormTemplate[]


Public Sub Add_Form_Template()

	Dim fNewForm as MyFormTemplate


	If MyArrayForm = NULL then
		MyArrayForm = New MyFormTemplate[]
	End If

	fNewForm = New MyFormTemplate

	fNewForm.IdForm = « your id »

	MyArrayForm.Add(fNewForm)

End


Nota: this is just an example

— 
Olivier Cruilles


Le 26 mars 2020 à 07:01:05, ub2 at gmx.ch (ub2 at gmx.ch) a écrit:

Dear Gambas Cracks  

2nd try, 1st see below  
(Was user at lists.gambas-basic.org partially down yesterday ?)  

Best regards  
ub2  


-------- Weitergeleitete Nachricht --------  
Betreff: How to duplicate Controls with all its preferences at runtime  
Datum: Wed, 25 Mar 2020 10:21:48 +0100  
Von: ub2 at gmx.ch <ub2 at gmx.ch>  
An: user at lists.gambas-basic.org  
Kopie (CC): ub2 at gmx.ch  

Dear Gambas Cracks  


I'm fiddling since 2 days, code explodes, and I'm sure there must be a  
better way ...  


I'd like to duplicate at runtime various Controls (different types!)  
with all it's preferences (Formatting, Pictures, etc).  

The situation:  
In a scrollview I have "a well prepared Master-Controls-line" like  
TglBtn_...._0 | Txta_....._0 | Txtlbl_..._0 | Pixcb_..._0 | ...  

In order to get new "Record-Lines" I'd like to duplicate all those  
Master-Controls them with the clumsy code partially shown in  
Attachement 200325...  
and access the Controls later with:  
$Ctrl$ = Me.Txtlbl_....._1  
$Ctrl$ = Me.Txtlbl_....._2  
...  

I'd like to avoid SubForms like:  
$NewUFrm$ = New UFrmXYZ($RecNr$, ..., ..., $Scrvw$)  
because access to those new Controls becomes more complicated:  
$Txtlbl_...._0$ = UFrmXYZ(Me.Scrvw.Children[0]).Children[2]  


My Question:  
Is there a command like:  
$Ctrl_New$ = NewWithPrefs Control($CtrlParent$)  
$Ctrl_New$ = Duplicate Control($CtrlParent$)  
ore similar  

Any ideas, links, keywords, etc would be highly appreciated.  


Thanks for Gambas and this very helpful community.  
Take care and stay healthy  

ub2  




----[ http://gambaswiki.org/wiki/doc/netiquette ]----  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20200326/abf7063c/attachment.html>


More information about the User mailing list