fill image list from .gif in dir
-
- PlatinumLounger
- Posts: 4370
- Joined: 26 Apr 2010, 17:36
fill image list from .gif in dir
Possible to fill an imagelist with a .gif in c:\mydir\img\
note:
after maintain the .gif saved in imagelist, for the next use
note:
after maintain the .gif saved in imagelist, for the next use
-
- Administrator
- Posts: 78625
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: fill image list from .gif in dir
Perhaps code like this:
Code: Select all
Const strPath = "c:\mydir\img\"
Dim strFile As String
With Me.ImageList1.ListImages
strFile = Dir(strPath & "*.gif")
Do While strFile <> ""
.Add Picture:=LoadPicture(strPath & strFile)
strFile = Dir
Loop
End With
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4370
- Joined: 26 Apr 2010, 17:36
Re: fill image list from .gif in dir
tks.HansV wrote: ↑09 Feb 2022, 15:26Perhaps code like this:
Code: Select all
Const strPath = "c:\mydir\img\" Dim strFile As String With Me.ImageList1.ListImages strFile = Dir(strPath & "*.gif") Do While strFile <> "" .Add Picture:=LoadPicture(strPath & strFile) strFile = Dir Loop End With
but really i need to fill a imagecombobox with a little flag of states and international phone prefix...
similar:
flag<state><prefix>
flag of Italia-ITALIA_+39
have an idea?
-
- Administrator
- Posts: 78625
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: fill image list from .gif in dir
Lets say has index 4 in the image list.
Me.ImageCombo1.ComboItems.Add Text:="ITALIA - 39", Image:=4
Me.ImageCombo1.ComboItems.Add Text:="ITALIA - 39", Image:=4
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4370
- Joined: 26 Apr 2010, 17:36
Re: fill image list from .gif in dir
Problem...
I have The image of flag state without idetif prefix!
I have only italy.gif!!!
I need any images of states and related prefix Number,...
Can you help me for research....
-
- Administrator
- Posts: 78625
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: fill image list from .gif in dir
When you add the gif files to the ImageList:
This will store Italy.gif with Key value "Italy".
Then use
(I cannot test this myself)
Code: Select all
.Add Picture:=LoadPicture(strPath & strFile), Key:=Replace(strFile, ".gif". "")
Then use
Code: Select all
Me.ImageCombo1.ComboItems.Add Text:="ITALIA - 39", Image:="Italy"
Best wishes,
Hans
Hans
-
- Administrator
- Posts: 78625
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: fill image list from .gif in dir
You'll find lots of flags in this post. It's not up-to-date though.
Best wishes,
Hans
Hans
-
- Administrator
- Posts: 78625
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlatinumLounger
- Posts: 4370
- Joined: 26 Apr 2010, 17:36
Re: fill image list from .gif in dir
TKS.
But i need also the association flag+prefix+state
-
- Administrator
- Posts: 78625
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: fill image list from .gif in dir
See List of country calling codes and/or [url=https://countrycode.org/]Country Codes[/code]
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4370
- Joined: 26 Apr 2010, 17:36
Re: fill image list from .gif in dir
RESOLVED!HansV wrote: ↑09 Feb 2022, 15:26Perhaps code like this:
Code: Select all
Const strPath = "c:\mydir\img\" Dim strFile As String With Me.ImageList1.ListImages strFile = Dir(strPath & "*.gif") Do While strFile <> "" .Add Picture:=LoadPicture(strPath & strFile) strFile = Dir Loop End With
but i can add a .tag when add picture?
-
- Administrator
- Posts: 78625
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: fill image list from .gif in dir
Individual images in an ImageList control do not have a Tag, but you can use the Key property for this purpose:
.Add Picture:=LoadPicture(strPath & strFile), Key:=Replace(strFile, ".gif". "")
.Add Picture:=LoadPicture(strPath & strFile), Key:=Replace(strFile, ".gif". "")
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 564
- Joined: 27 Jun 2021, 10:46
Re: fill image list from .gif in dir
>Individual images in an ImageList control do not have a Tag
Erm ... are you quite sure?
Erm ... are you quite sure?
-
- Administrator
- Posts: 78625
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: fill image list from .gif in dir
No. It turns out they do have a tag. Sorry for the misinformation.
Me.ImageList1.ListImages.Add(Picture:=LoadPicture(strPath & strFile)).Tag = "Italy"
Me.ImageList1.ListImages.Add(Picture:=LoadPicture(strPath & strFile)).Tag = "Italy"
Best wishes,
Hans
Hans