PDA

View Full Version : Tell me what is wrong please...



Scranton
12-06-2003, 09:18 PM
I have a folder of jpg files being loaded into a list box. I have that part. With the following code on the page.

Folder = Folder.Find("AutoPlay\\Images\\oldfampics\\Sue Family", "jpg", false, nil);
pictures = File.Find("AutoPlay\\Images\\oldfampics\\Sue Family", "*.jpg", false, false, nil);
for j,file_path in pictures do
ListBox.AddItem("ListBox1", String.SplitPath(file_path).Filename, file_path);
end
ListBox.SetUpdate("ListBox1", true);

Now I want to be able to select the file from the list and have it display the jpg on the image object.

Here is my code on the list box but it isn't working. I also have an empty image object on the menu for the image to display in.

selected = ListBox.GetSelected("ListBox1");
for j in selected do
Image.Load("Image1", ListBox.GetItemData("ListBox1", file_path));
end


Any help would be greatly appreciated. I'm cross-eyed looking at this thing.

Thanks for any help.

TJ_Tigger
12-07-2003, 09:30 AM
if you are only allowing single selection you can use the following code to load the image.

selected = ListBox.GetSelected("ListBox1");
Image.Load("Image1", selected[1]);

You don't need to enumerate the table if it is for single selection

Scranton
12-07-2003, 04:19 PM
I appreciate your help. I cut and pasted your code onto my listbox actions under both double click and select and tried to run the project. When you do either on the list box when it is running, it still doesn't show anything in the image box.

The list box is being populated with the names of jpg photos automatically when it is started. From that list I want to be able to make a selection and have that one selection show the picture in the image box next to it. So I am only selecting one picture to view at a time.

Any ideas?

TJ_Tigger
12-07-2003, 07:34 PM
Here is a project that I did that might show you what you are looking for.

Get it here (http://home.mchsi.com/~tj-tigger/pub/picture_viewer.zip)

If you are only allowing single selection you do not need to enumerate the table from you ListBox selection.

selected = ListBox.GetSelected("ListBox1");
Image.Load("Image1", ListBox.GetItemData("ListBox1", selected[1]));

Scranton
12-08-2003, 03:19 PM
TJ_Tigger, many many thanks!!! I can see straight again. That last bit of code worked perfectly. I certainly appreciate the help!

Thanks again.

TJ_Tigger
12-08-2003, 06:32 PM
NP I am glad it helped.