My question is: why does ItemIndex =0 not work when I add the items in a Sub as shown in the example below? I have to use a Sub because the data for the listbox are read from file during run time.
Second question: When I press the Cursor Down key then "Choice # 0 Allan" appears in the EditText box. Is it possible to make this shown without a key press at program start? Help is very much appreciated.
DECLARE SUB ItemClick DECLARE SUB AddItem CREATE Form AS QFORM CREATE ListBox AS QLISTBOX Left = 90 Top = 20 ItemIndex = 0 '<- that's the trouble Sorted = 1 OnClick = ItemClick END CREATE CREATE Edit AS QEDIT Left = 90 Top = 150 END CREATE END CREATE ItemAdd Form.ShowModal
SUB ItemAdd ListBox.AddItems "Fred", "Ben", "Larry", "Tom",_ "Will","John","Allan","Charles" END SUB SUB ItemClick Edit.Text = "Choice # " & STR$ (ListBox.ItemIndex)_ & " " & ListBoxItem (Listbox.ItemIndex) END SUB