B4J Question How to set combobox item using item value

rfresh

Well-Known Member
Licensed User
Longtime User
I have a ComboBox of altitudes

B4X:
        cboAlt(i).Items.Add("0.000000")
        cboAlt(i).Items.Add("1000")
        cboAlt(i).Items.Add("1500")
        cboAlt(i).Items.Add("2000")
        cboAlt(i).Items.Add("2500")
        cboAlt(i).Items.Add("3000")
        cboAlt(i).Items.Add("3500")
        cboAlt(i).Items.Add("4000")
        cboAlt(i).Items.Add("4500")
        cboAlt(i).Items.Add("5000")
        cboAlt(i).Items.Add("5500")
        cboAlt(i).Items.Add("6000")
        cboAlt(i).Items.Add("6500")
        cboAlt(i).Items.Add("7000")
        cboAlt(i).Items.Add("7500")
        cboAlt(i).Items.Add("8000")
        cboAlt(i).Items.Add("8500")
        cboAlt(i).Items.Add("9000")
        cboAlt(i).Items.Add("9500")

If I have a variable = 4500 how can I set the combo selectedIndex using that 4500 value? Is there some kind of find I can use?

Thank you...
 

mangojack

Expert
Licensed User
Longtime User
normal ComboBox ..
B4X:
combo1.SelectedIndex = combo1.Items.IndexOf(var)

If using B4XComboBox (Recommended}...
B4X:
combo1.SelectedIndex = combo1.IndexOf(var)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…