|
-
Jan 19th, 2018, 01:56 PM
#1
Thread Starter
Junior Member
I'm unable to loop on imagelist in visual basic 6.0
I want to make a program like this 'see one of this two links'..https://ufile.io/y1qm9 or this https://ibb.co/jGobgm
The program for children ,combines two numbers with a combined output show in the form of a number of apples.
but I can't loop on imagelist , this is the code/;
Private Sub Command1_Click()
ListView1.View = lvwIcon
Dim i, x, y As Integer
x = CInt(Text1.Text) + CInt(Text2.Text)
For y = 1 To x
ImageList1.ListImages.Add , "s" & y, LoadPicture("C:\Users\pc1\Desktop\2911 copy.jpg")
Next y
For i = 1 To x
ListView1.ListItems.Add , "M" & i, "Apple" & i, i
Next i
End Sub
the error code :
ImageList must be intialized it can be used.
-
Jan 19th, 2018, 02:05 PM
#2
Re: I'm unable to loop on imagelist in visual basic 6.0
I think you should've just kept this thread with your previous thread.
The error is because you want to first assign the image list to your listview. You do that via the custom properties of the listview. Right click on listivew and choose the properties menu item.
Now, you don't add a single image multiple times to the imagelist. You just add it once. Doing otherwise is an abuse of system resources IMO.
Couple things.
1. If your project will have a specific list of images, you can pre-load them into the imagelist instead of trying to load them at runtime. Right click on the ImageList control and choose the properties menu item. If you are going to do that, and before any images are added, set the picture size within that properties window first.
2. If adding images at runtime, you will want to set the imagelist picture size before you add any images.
3. Just FYI. The imagelist can only contain images of one size. If the image doesn't fit that size, it will be stretched to fit. If multiple sizes are needed, you typically use multiple imagelists.
-
Jan 19th, 2018, 02:10 PM
#3
Re: I'm unable to loop on imagelist in visual basic 6.0
Which line does the error happen on? When adding to the ImageList or the ListView? It sounds like it happens when you add to the listview... odds are the .ImageList property of the ListView hasn't been set to your ImageView ... if you want the LV to use images from the IV, you need to tell one about the other.
set ListView1.ImageList = ImageView1
Then you can use the imageview icons in the list view... you can also set it at design time.
-tg
-
Jan 20th, 2018, 01:08 AM
#4
Thread Starter
Junior Member
Re: I'm unable to loop on imagelist in visual basic 6.0
[QUOTE=LaVolpe;5253557]
Now, you don't add a single image multiple times to the imagelist. You just add it once. Doing otherwise is an abuse of system resources IMO.
I have only a single image trying to add it to the listview many times as equal to a given number defined by the user. what the code for this ?
-
Jan 20th, 2018, 01:10 AM
#5
Thread Starter
Junior Member
Re: I'm unable to loop on imagelist in visual basic 6.0
I have only a single image trying to add it to the listview many times as equal to a given number defined by the user. what the code for this ?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|