advansis Active Member Licensed User Longtime User Oct 18, 2019 #1 Hi guys, I have several B4XPlusMinus controls in my activity. I want to use a FOR..NEXT loop to populate the values. What I do is in the following code: Code: For Each V As View In Activity.GetAllViewsRecursive If V Is B4XPlusMinus Then Dim PM As B4XPlusMinus=V PM.SetNumericRange(0,255,1) End If Next Unfortunally, the code, as is, doesn't work. I know the error is in the 3rd line (Dim PM as ...), is there another way to cast the View as B4XPlusMinus? Thanks in advance
Hi guys, I have several B4XPlusMinus controls in my activity. I want to use a FOR..NEXT loop to populate the values. What I do is in the following code: Code: For Each V As View In Activity.GetAllViewsRecursive If V Is B4XPlusMinus Then Dim PM As B4XPlusMinus=V PM.SetNumericRange(0,255,1) End If Next Unfortunally, the code, as is, doesn't work. I know the error is in the 3rd line (Dim PM as ...), is there another way to cast the View as B4XPlusMinus? Thanks in advance
LucaMs Expert Licensed User Longtime User Oct 19, 2019 #2 Code: For Each V As B4XView In Activity.GetAllViewsRecursive If V.Tag Is B4XPlusMinus Then Dim PM As B4XPlusMinus = V.Tag PM.SetNumericRange(0,255,1) End If Next Last edited: Oct 19, 2019 Upvote 0
Code: For Each V As B4XView In Activity.GetAllViewsRecursive If V.Tag Is B4XPlusMinus Then Dim PM As B4XPlusMinus = V.Tag PM.SetNumericRange(0,255,1) End If Next
Erel B4X founder Staff member Licensed User Longtime User Oct 19, 2019 #3 The explanation for the correct answer above, is that the custom view instance is not a view by itself. It adds to the views tree a panel (V in this code). XUI Views set the panel's tag property to the class instance: Code: mBase.Tag = Me This makes it easy to get the class instance from the views tree. Note that there is another Tag property in these custom views that you can use if needed. Upvote 0
The explanation for the correct answer above, is that the custom view instance is not a view by itself. It adds to the views tree a panel (V in this code). XUI Views set the panel's tag property to the class instance: Code: mBase.Tag = Me This makes it easy to get the class instance from the views tree. Note that there is another Tag property in these custom views that you can use if needed.