Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[solved] how to - list box with elements from array
#1
Hi,

I have an array of values that I'd like displayed in a list box for the user to select.

for example, the array has blue,red,green

and the list box would pop up
blue
red
green

The array often changes so this listbox needs to be dynamic.

Thanks
#2
Is it a listbox control in your dialog?
When to populate the listbox?
1. Before showing dialog.
2. While showing dialog, eg when a button pressed.
#3
re: Is it a listbox control in your dialog?
Sorry, I'm not sure. I don't have a listbox or dialog. I looked at listbox but that seems static. Maybe smart dialog or custom dialog is what I need?

re:When to populate the listbox?
When a button is pressed.

If possible, I want the list to show up when an event trigger occurs.

I'm basically trying to get a list of urls to show up so I can pick one to make a link.
#4
Macro Macro2239
Code:
Copy      Help
ARRAY(str) a="one[]two"
str s=a
int i=ShowMenu(s 0 0 2)
if(i>0) out a[i-1]
#5
Awesome. Thank you!
#6
Your example works fine, but I can't get it to work on my code. I tried reading the help file but I can't understand what the two zeroes do. One of them controls the mouse position. The other...well, there's no other zero that I can see in the help file so I'm confused.

My code

a is a two dimension array array. I'd like to get the 2nd dimension to show up so a[2 j] where 2 refers to the 2nd column

Code:
Copy      Help
str s=a
int i=ShowMenu(s 0 0 2)
if(i>0) out a[2 i-1]

Thank you.
#7
str s=a creates multiline text only if a has 1 dimension.

str s
for(i 0 a.len) s.addline(a[2 i])
#8
It's perfect. Thanks again, Gintaras!


Forum Jump:


Users browsing this thread: 1 Guest(s)