Hi, running the following I get a casting error (in the tempToggle_selectedChanged sub), while follows a way that does not produce an error. Do I handle it the wrong way in the first sub?
B4X:
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private aPane As AnchorPane
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
createExample
End Sub
Sub createExample
aPane.Initialize ("")
MainForm.RootPane.AddNode(aPane,0,0,300,140)
Dim tempToggle As ToggleButton
Dim tempCombo As ComboBox
tempToggle.Initialize ("tempToggle")
tempToggle.Text="toggle"
aPane.AddNode(tempToggle,0,0,200,60)
tempCombo.Initialize ("")
tempCombo.Items.Add("something")
aPane.AddNode(tempCombo,0,80,200,60)
End Sub
' the following produces a casting error, cause we're trying to set a combo as a toggle
Sub tempToggle_SelectedChange(Selected As Boolean)
For Each tempT As ToggleButton In aPane
tempT.Text="ok"
Next
End Sub
' the following works
'Sub tempToggle_SelectedChange(Selected As Boolean)
' For Each tempT As Node In aPane
' If tempT Is ToggleButton Then
' Dim tempT2 As ToggleButton
' tempT2=tempT
' tempT2.Text="ok"
' End If
' Next
'End Sub