Hi,
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
listbox confusion
Re: listbox confusion
I think you just need to use the .Text property, example:-
Me.Text = ListBox1.Text..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:-
Public Sub ListBox1_Click() Me.Text = ListBox1.Text End
- BruceSteers
- Posts: 387
- Joined: Thursday 23rd July 2020 5:20pm
Re: listbox confusion
Also Listbox1.List is a String[] array
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
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
Wishing well
Bruce
If at first you don't succeed , try it differently.
Bruce
If at first you don't succeed , try it differently.
Re: listbox confusion
Thank you very much! Just what I needed.
Your help was greatly appreciated
Carl
Your help was greatly appreciated
Carl