Listview Control

Post

Posted
Rating:
#1 (In Topic #761)
Avatar
Regular
cage is in the usergroup ‘Regular’
 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.
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
This code works as expected adding an item to the ListView then changing the image….

Code (gambas)

  1.  
  2. Public Sub Form_Open()
  3.  
  4.   ListView1.Add("i1", "Item1", Picture["icon:/16/added"])
  5.   ListView1["i1"].Selected = True
  6.  
  7.  
  8.  
  9. Public Sub Button1_Click()
  10.  
  11.   ListView1["i1"].Picture = Picture["icon:/16/bookmark"]
  12.  
  13.  
  14.  
  15. Public Sub Button2_Click()
  16.  
  17.   ListView1["i1"].Picture = Picture["icon:/16/agenda"]
  18.  
  19.  
Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’

cage said

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 :(
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Regular
cage is in the usergroup ‘Regular’
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:

Code (gambas)

  1.   ListView1.Add("i1", "First Item1", Picture["cabinet.ico"])
  2.   ListView1.Add("i2", "Second Item2", Picture["Applauncher.ico"])
  3.   ListView1["i1"].Selected = True

<IMG src=""> </IMG>

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.

Image

(Click to enlarge)

Online now: No Back to the top

Post

Posted
Rating:
#5
Guru
BruceSteers is in the usergroup ‘Guru’

cage said

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:

Code (gambas)

  1.   ListView1.Add("i1", "First Item1", Picture["cabinet.ico"])
  2.   ListView1.Add("i2", "Second Item2", Picture["Applauncher.ico"])
  3.   ListView1["i1"].Selected = True

<IMG src=""> </IMG>

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
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Regular
cage is in the usergroup ‘Regular’
Thanks again Bruce, that did the trick.
Online now: No Back to the top
1 guest and 0 members have just viewed this.