listbox confusion
Posted
#1
(In Topic #535)
Trainee
I am very new to Gambas, and respectfully request help on using a listbox. I have created a listbox and added several items. What I would like to do is select an item from the list and save the item in a string variable for use elsewhere in my program. I can retrieve the index number without problem, but can't load the actual string value of the item itself. I'm sure it must be simple, but I can't find any details how to do this.
Any help is greatly appreciated
Posted
Regular

carlhood said
…What I would like to do is select an item from the list and save the item in a string variable…
I think you just need to use the .Text property, example:-
Code (gambas)
..will return the selected item in the listbox (…and in this case display it as the Form's caption).
I hope this helps.
…Oh, and if you want to do this every time an item is selected:-
Posted
Guru

So if you have the index you can do this…
sText = ListBox1.List[iIndex]
For sending text the other way from the variable to the list you have to make a new array.
ListBox1.List[iIndex] = sText ' This does not work
Dim aTemp As String[] = ListBox1.List.Copy()
aTemp[iIndex] = sText
ListBox1.List = aTemp
'That does work
Posted
Trainee
Your help was greatly appreciated
Carl
1 guest and 0 members have just viewed this.


