Listview Control

Post your Gambas programming questions here.
Post Reply
cage
Posts: 123
Joined: Monday 2nd September 2019 5:47am
Location: Phoenix Arizona

Listview Control

Post by cage »

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.
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Listview Control

Post by BruceSteers »

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
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Listview Control

Post by BruceSteers »

cage wrote: Saturday 6th November 2021 8:08pm 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.
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
cage
Posts: 123
Joined: Monday 2nd September 2019 5:47am
Location: Phoenix Arizona

Re: Listview Control

Post by cage »

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
Image

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
Listview.png (23.09 KiB) Viewed 3039 times
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Listview Control

Post by BruceSteers »

cage 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
Image

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're welcome :)
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
cage
Posts: 123
Joined: Monday 2nd September 2019 5:47am
Location: Phoenix Arizona

Re: Listview Control

Post by cage »

Thanks again Bruce, that did the trick.
Post Reply