Indigo Rose Software
  #1  
Old 11-03-2003
John-oh's Avatar
John-oh John-oh is offline
Indigo Rose Customer
 
Join Date: Jun 2000
Location: England
Posts: 200
ListBox Woes

I am using a ListBox to open various (predefined) files.

I am using a suggested script (modified) from the help files "how do I?"

I have a ListBox with a button underneath, with the following code 'on press'

selected = ListBox.GetSelectedCount("ListBox1");
file = ListBox.GetItemData("ListBox1", selected);
if file == "" then
Dialog.Message("Notice", "You must select a file from the list above ...", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
File.Open(file, "", SW_SHOWNORMAL);
end

The dialog message works Ok, when no file selected.

But, I always get the file that is first on the list (position 1), no matter which file is selected in the list box.

I've tried various tweaks, like setting selected="" at the begining and reseting the list at the end, but it makes no difference.
I assume by now that I'm missing something blindingly obvious.

Anyone help ?

Cheers:(
Reply With Quote
  #2  
Old 11-03-2003
Lorne's Avatar
Lorne Lorne is offline
Indigo Rose Staff Member
 
Join Date: Feb 2001
Location: Indigo Rose Software
Posts: 2,588
You're using GetSelectedCount()...which returns the number of items that are currently selected.

Then you use that "count" as the index of the item...oops.

You want to use GetSelected instead.

Try this instead:

tSelected = ListBox.GetSelected("ListBox1");
file = ListBox.GetItemData("ListBox1", tSelected[1]);

...although if you have the listbox set up to allow multiple selection, you should rewrite your code to go through the tSelected table and open all of the selected files.
Reply With Quote
  #3  
Old 11-03-2003
John-oh's Avatar
John-oh John-oh is offline
Indigo Rose Customer
 
Join Date: Jun 2000
Location: England
Posts: 200
Lorne,

Excellent, all works as expected now.

Thanks.

I beleive that makes the Helpfile section :

How do I ? - Create a file browser - incorrect, as thats where I got the script from.

Thanks again.
Reply With Quote
  #4  
Old 11-03-2003
Darryl's Avatar
Darryl Darryl is offline
Indigo Rose Staff Member
 
Join Date: Jul 2001
Location: Indigo Rose Software
Posts: 1,602
Thanks, we'll get that fixed up.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -6. The time now is 08:27 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software