Populate Select List Based on Drop-Down Selection
This is a demo program on how you can populate a list box based on a selected field.
This is a demo program on how you can populate a list box based on a selected field. You first select the file, you will then be given a list of the character fields within the file. You select a field and in the background the script will summarize the field and get all the unique items in that field and place them in a list box so you can select one or more items.
Hi Benoit,
Hi Benoit,
Yes it is but you must set the default before you call the dialog, you can't set a default once the dialog is open. Here is some example code for you, you can copy it and paste it into your IDEAScript editor. It has a dialog with a list of fruit, it sets the default to item 3 (which is actually the 4th item as arrays start at 0).
Dim listbox1$() AS STRING
Begin Dialog NewDialog 50,50,150,150,"NewDialog", .NewDialog
DropListBox 18,15,90,11, listbox1$(), .DropListBox1
OKButton 21,61,40,14, "OK", .OKButton1
End Dialog
Sub Main
Dim dlg As NewDialog
Dim button As Integer
ReDim listbox1$(4)
listbox1$(0) = "Apples"
listbox1$(1) = "Oranges"
listbox1$(2) = "Grapes"
listbox1$(3) = "Bananas"
listbox1$(4) = "Lemons"
dlg.DropListBox1 = 3
button = Dialog(dlg)
End Sub
The lisbox1 is an array so
The lisbox1 is an array so what you need to do is find out which value in the array is the same as the value you want as the default. I have modified my example above so that it will select Oranges as the default.
Sub Main
Dim dlg As NewDialog
Dim button As Integer
ReDim listbox1$(4)
listbox1$(0) = "Apples"
listbox1$(1) = "Oranges"
listbox1$(2) = "Grapes"
listbox1$(3) = "Bananas"
listbox1$(4) = "Lemons"
'assume you are interested in Oranges being the default
For i = 0 To UBound(listbox1$)
If "Oranges" = listbox1$(i) Then
Exit For
End If
Next i
dlg.DropListBox1 = i
button = Dialog(dlg)
End Sub
Hi Brian,
Hi Brian,
Do you know if it's possible to have a value by default to the droplistbox1 ? (and the items attached to this value into the listbox1) ?
Thanks.
Benoit