Give the Picture-Variable the name of the picture via a string?

I have a Picture in an ImageView:
ImageView_Artikel1.Picture

I load a .csv file into my project, extract the names of the articles and want to load the pictures with this name.
The pictures are in my Xojo project. I drag & drop it into the project.

When I’m using this, it works:

ImageView_Artikel1.Picture = H8-HK13234

But the problem is, I have the names in strings, and want to give the pictures the names.

DIM String_NameBild1 As String
String_NameBild1 = “H8-HK13234.png”

ImageView_Artikel1.Picture = String_NameBild1

But then I got a type mismatch.

How can I give the Picture-Variable the name of the picture via a string?

That’s not possible.

Because you are trying to assign a String Object (String_NameBild1) to a Picture Object (ImageView_Artikel1.Picture).

But you could f.e. create an Array of Pictures and Strings and store and store each there.

Like this:
thePicture(1) = H8-HK13234
thePictureName(1) = “H8-HK13234.png”

If you later use thePicture(1), you know that thePictureName(1) contains the Name of the Picture.

[quote=210876:@Thomas Mueller]I have a Picture in an ImageView:
ImageView_Artikel1.Picture

I load a .csv file into my project, extract the names of the articles and want to load the pictures with this name.
The pictures are in my Xojo project. I drag & drop it into the project.

When I’m using this, it works:

ImageView_Artikel1.Picture = H8-HK13234

But the problem is, I have the names in strings, and want to give the pictures the names.
[/quote]

Use a dictionary. It will let you store the picture in a string key.

I am unsure, but why don’t you load the image from the Photos_Articles folder using its name and then set this to ImageView_Artikel1.Picture ?

Open the image from its folder (path to the Photos_Articles folder folder .Child ) into a local Picture variable
then apply that local Picrure variable to ImageView_Artikel1.Picture.

Ask for more details if not enough.

Because at the opening of the app, I don’t know, which photos I’ll need.

The .csv - file with the names shows me, what pictures I have to load and show.

So you need code that does something like

  1. read csv to get the name of the picture file on disk to load
  2. load the picture by name from disk

I have no idea how your code works
But lets say you get a string variable, called PictureName, with the name of the picture in it

Then something along the lines of

   dim fi as folderitem = GetFolderItem(PictureVariable)
    dim p as picture = Picture.Open(fi)
    ImageView_Artikel1.Picture = p

[quote=210926:@Thomas Mueller]Because at the opening of the app, I don’t know, which photos I’ll need.

The .csv - file with the names shows me, what pictures I have to load and show.[/quote]
Yes, but you have all the images handly, somewhere in a defined folder.

So, you define a FolderItem that point to that folder and define a FolderItem for this image using f.Child(ImageName) … then you load it.

Norman simili code looks what I had in mind (but was not really able to explain yesterday).

If this is not enough, explain why / explain from where you take the image to display and we may be able to give a better hint.

I would create a class for this. Give the class two properties: picture and string

Perhaps the solution would be, that I don’t drag & drop the pictures into the project.

Now, I think the better way would be: I upload the pictures to an apache server, and load them - when I need them.

But I don’t know how I can load an external picture into a image.

EDIT: Ok, got it: with the .URL = “”, I can load external pictures. :slight_smile:

That way is the fastest display, and it does not tax the app resources. That is what I usually do.

I like this . as sometimes so many picutures,I just don’t want to drag it one by one. and want to all images from some folder.

but which version ‘s Picture has a property of “URL” ,???

This refers to a WebImageView. In Xojo Web.

that[quote=303769:@Michel Bujardet]This refers to a WebImageView. In Xojo Web.[/quote]

that’s ok,thanks