Listview Control
Listview Control
I have trying to use a Listview control but nothing I have found seems to display the picture in the list. Most of what I have found on the internet was written back in 2005. If anyone can help I would greatly appreciate it.
- BruceSteers
- Posts: 1623
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Listview Control
This code works as expected adding an item to the ListView then changing the image....
Public Sub Form_Open()
ListView1.Add("i1", "Item1", Picture["icon:/16/added"])
ListView1["i1"].Selected = True
End
Public Sub Button1_Click()
ListView1["i1"].Picture = Picture["icon:/16/bookmark"]
End
Public Sub Button2_Click()
ListView1["i1"].Picture = Picture["icon:/16/agenda"]
End
If at first you don't succeed , try doing something differently.
BruceS
BruceS
- BruceSteers
- Posts: 1623
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Listview Control
PS.
I find the as-you-type Auto-complete text is much more up to date with help than the wiki.
that's how i found the ListView Items Picture property.
Like you i found nothing on the wiki
If at first you don't succeed , try doing something differently.
BruceS
BruceS
Re: Listview Control
Thanks Bruce. I had to remove the icon/16/ to make it display the icon but really small. I take it only uses icon files and not png icons. I will do some more experiments with it.
Here is what I did to the code:
I used Pinta image program to convert the png files to ico and to a size I wanted to try. Once again thank your for your help. It is greatly appreciated.
Here is what I did to the code:
ListView1.Add("i1", "First Item1", Picture["cabinet.ico"])
ListView1.Add("i2", "Second Item2", Picture["Applauncher.ico"])
ListView1["i1"].Selected = True
I used Pinta image program to convert the png files to ico and to a size I wanted to try. Once again thank your for your help. It is greatly appreciated.
- Attachments
-
- Listview.png (23.09 KiB) Viewed 3375 times
- BruceSteers
- Posts: 1623
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Listview Control
You're welcomecage wrote: ↑Sunday 7th November 2021 1:43am Thanks Bruce. I had to remove the icon/16/ to make it display the icon but really small. I take it only uses icon files and not png icons. I will do some more experiments with it.
Here is what I did to the code:
ListView1.Add("i1", "First Item1", Picture["cabinet.ico"]) ListView1.Add("i2", "Second Item2", Picture["Applauncher.ico"]) ListView1["i1"].Selected = True
I used Pinta image program to convert the png files to ico and to a size I wanted to try. Once again thank your for your help. It is greatly appreciated.
You should be able to use any image format that Picture.Load() supports with any path.
Using the path "icon:/" shows all the gambas png stock icons. (If you type icon:/ in the name field it will popup a list of all the size folders for required icon size)
you could do a quick resize to any desired fixed size using the Pictures Image property when loading it.
Picture["cabinet.ico"].Image.Stretch(32,32).Picture
If at first you don't succeed , try doing something differently.
BruceS
BruceS
Re: Listview Control
Thanks again Bruce, that did the trick.