Yvon Steinthal Active Member Licensed User Longtime User Jun 15, 2016 #1 Hi, I have a question regarding the possibility of looping intialization of views. In other words, i have a bunch of textfields and labels that i want to send to a function to initialize them all such as this: Replace: Code: Private txtbox as TextField txtbox.initialize("") txtbox.font=createnew2(...,14) Mainpanel.addview(txtbox,20,20...) By: Code: Private txtbox as TextField buildElement(txtbox) Sub buildElement(txtbox as (?), ini as string, fontsize as int, left, top...) txtbox.initialize(ini) txtbox.font=createnew2(...,fontsize) Mainpanel.addview(txtbox,left,top...) End Sub Is that possible? or do i have to go through each of my 120 textboxes and labels to set the initialization and the font size...?
Hi, I have a question regarding the possibility of looping intialization of views. In other words, i have a bunch of textfields and labels that i want to send to a function to initialize them all such as this: Replace: Code: Private txtbox as TextField txtbox.initialize("") txtbox.font=createnew2(...,14) Mainpanel.addview(txtbox,20,20...) By: Code: Private txtbox as TextField buildElement(txtbox) Sub buildElement(txtbox as (?), ini as string, fontsize as int, left, top...) txtbox.initialize(ini) txtbox.font=createnew2(...,fontsize) Mainpanel.addview(txtbox,left,top...) End Sub Is that possible? or do i have to go through each of my 120 textboxes and labels to set the initialization and the font size...?
Erel B4X founder Staff member Licensed User Longtime User Jun 16, 2016 #2 It is possible. The type should match the object type. You can also find all the relevant views and set their font property: Code: For Each v As View In Page1.RootPanel.GetAllViewsRecursive If v Is Label Then Dim lbl As Label = v lbl.Font = ... Else if v Is TextField Then Dim tf As TextField = v tf.Font = ... Else if v Is TextView Then Dim tv As TextView = v tv.Font = ... End If Next Upvote 0
It is possible. The type should match the object type. You can also find all the relevant views and set their font property: Code: For Each v As View In Page1.RootPanel.GetAllViewsRecursive If v Is Label Then Dim lbl As Label = v lbl.Font = ... Else if v Is TextField Then Dim tf As TextField = v tf.Font = ... Else if v Is TextView Then Dim tv As TextView = v tv.Font = ... End If Next