how to preselect spinner

cwt

Active Member
Licensed User
Longtime User
I have a spinner that is already populated from a table. How can I set the selected spinner row to the value of another variable so that after the spinner populates is displays the variable value? The variable value will always be one of the choices in the spinner.

Thanks
 

cwt

Active Member
Licensed User
Longtime User
What is "Value" and what do I set it to? The compiler is saying it must be an array.

Thanks
 
Upvote 0

cwt

Active Member
Licensed User
Longtime User
Here is what I am doing:

I fill the Spinner with text fields from a table.
A string variable is set to one of the same values that the spinner is filled with.

Then I want the spinner to show the value of the string variable.

I must not be understanding something basic here.

Sub BuildSpinnerList
Dim Cur As Cursor
Spinner1.Add("job status list")
Cur = Main.SQL1.ExecQuery("SELECT * FROM " & Main.StatusTableName & " ORDER BY Status ASC" )
For i = 0 To Cur.RowCount - 1
Cur.Position = i
Spinner1.Add(Cur.GetString("Status"))
Next
Cur.Close
End Sub

Let's say one of the values that was added to the spinner was "xyz"

Now I set the string variable JobStatus = "xyz"

As soon as I set JobStatus to "xyz" I want the spinner to show "xyz" - preselected, so to speak.

Thanks
 
Upvote 0

admac231

Active Member
Licensed User
Longtime User
Sorry I was a bit of an idiot there. It should be
B4X:
Spinner1.SelectedIndex = Spinner1.IndexOf(JobStatus)
Also, you can give your spinner a title by using Spinner1.Prompt = "Title". I'm assuming that's what you're doing with Spinner1.Add("job status list").
 
Upvote 0
Top