Hi everyone,
I have a problem getting the selected index in a B4XComboBox inside a B4X dialog. If you select anything else than selectedindex 0 nothing is selected and loops again as it is supposed to do. The same code works perfect in B4A. Debugging it I noticed that if you select an index greater than 0 the selectedindex turns to -1 (Checked in the line immediately after the asterisks). I use XUI Views v2.13.
Here is the code:
I have a problem getting the selected index in a B4XComboBox inside a B4X dialog. If you select anything else than selectedindex 0 nothing is selected and loops again as it is supposed to do. The same code works perfect in B4A. Debugging it I noticed that if you select an index greater than 0 the selectedindex turns to -1 (Checked in the line immediately after the asterisks). I use XUI Views v2.13.
Here is the code:
B4X:
Sub GetNumber As ResumableSub
Dim dialog As B4XDialog
Dim xui As XUI
Dim p As B4XView = xui.CreatePanel("")
Dim lv As LayoutValues = GetDeviceLayoutValues
p.SetLayoutAnimated(0, 0, 0, lv.Width*0.8, lv.Height*0.6)
p.LoadLayout("GetNum")
locmain.LocalizeLayout(p)
dialog.Initialize(Page1.RootPanel)
Dim l As List
l.Initialize
l.Add("- Please select -")
For ii = 1 To 10
l.Add(ii)
Next
cmbGetNum.SetItems(l)
Dim iNum As Int
Dim bProceed As Boolean = False
Do While bProceed = False
dialog.PutAtTop = True 'put the dialog at the top of the screen
Wait For (dialog.ShowCustom(p, locmain.Localize("Ok"), "", locmain.Localize("Cancel"))) Complete (Result As Int)
'*******************************************
Dim iSel As Int = cmbGetNum.SelectedIndex
If Result = xui.DialogResponse_Positive Then
Select Case iSel
Case -1
'
Case 0
'
Case Else
iNum = cmbGetNum.GetItem(iSel)
bProceed = True
End Select
Else If Result = xui.DialogResponse_Cancel Then
iNum = -1
bProceed = True
End If
Loop
Return iNum
End Sub
Last edited: