J jGubern Member Licensed User Longtime User Nov 13, 2019 #1 I would like to replace the text of several Textfield with code. How can I access these views from code? I guess something like MainForm.RootPane ........ But I am not able to get it. (rookie) any suggestions? Thanks
I would like to replace the text of several Textfield with code. How can I access these views from code? I guess something like MainForm.RootPane ........ But I am not able to get it. (rookie) any suggestions? Thanks
Erel B4X founder Staff member Licensed User Longtime User Nov 13, 2019 #2 There are all kinds of ways. Example of clearing all TextFields: Code: Copy 'Add reference to XUI Dim parent As B4XView = MainForm.RootPane For Each x As B4XView In parent.GetAllViewsRecursive If x Is TextField Then x.Text = "" Next In many cases it is better to create an array or list with the relevant views: Code: Copy Dim Fields As List = Array(TextField1, TextField2, ...) 'later Dim tf As TextField = Fields.Get(1) 'second one tf.Text = "abc" Upvote 0
There are all kinds of ways. Example of clearing all TextFields: Code: Copy 'Add reference to XUI Dim parent As B4XView = MainForm.RootPane For Each x As B4XView In parent.GetAllViewsRecursive If x Is TextField Then x.Text = "" Next In many cases it is better to create an array or list with the relevant views: Code: Copy Dim Fields As List = Array(TextField1, TextField2, ...) 'later Dim tf As TextField = Fields.Get(1) 'second one tf.Text = "abc"
J jGubern Member Licensed User Longtime User Nov 13, 2019 #3 OMG, How fast and complete the answer! The answer is perfect for my case. Many thanks. Upvote 0