VBForums >
.NET >
C# > loading image instead of text in listview - C# *resolved*
Click to See Complete Forum and Search --> : loading image instead of text in listview - C# *resolved*
Colonel Klink
Sep 7th, 2003, 05:52 PM
im wanting to load an image (thats 50x50), instead of a string, into a listview column (not the header)
not ness. the first column, but any.
ive tried using Bitmap.FromFile, but i get an error (cant convert the image to a string)
how, if possible, would one accomplish this?
PT Exorcist
Sep 8th, 2003, 01:54 AM
i think it will be very very hard as the listview doesnt allow each item to be drawn by itself as the combobox/listbox allow..so only maybe with a lot of subclassing :(
Colonel Klink
Sep 8th, 2003, 09:16 AM
damn :(
how about a listbox then?
PT Exorcist
Sep 8th, 2003, 12:47 PM
could u explain what u really wanna do plz so it might be easier to help?
Pirate
Sep 8th, 2003, 02:03 PM
You mean loading an image in the item collection of the listview as in the attachment ?
Colonel Klink
Sep 8th, 2003, 03:17 PM
thats the one Pirate :)
except an image thats 50x50 or 100x100
how would i do this?
btw... its also gotta have text with it in other columns
Pirate
Sep 8th, 2003, 03:26 PM
Easy . Add your images to ImageList , set Width and Height to whatever (50X50 or 100X100) . Bind it to the listview(3 steps I believe) StateImageList , SmallImageList and LargeImageList all = the imageList control. Add items , from there you can set imageindex to be shown in the listview .
Pirate
Sep 8th, 2003, 03:38 PM
In the items collection of the listview, add set Text property to each item in the collection . I've not tried that but it sounds obvious .
Colonel Klink
Sep 8th, 2003, 04:43 PM
oh ok... i was under the impression that i would need to do some subclassing to do an image other than 16x16 or whatever... thanks :D
Pirate
Sep 9th, 2003, 10:47 AM
I think PT Exorcist meant combobox or listbox subclassing to hold these images . Right PT Exorcist ?;)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.