ListView

nathansav

Registered User.
Local time
Yesterday, 16:10
Joined
Jul 28, 2010
Messages
114
Hi,

I have recently used a image combo box and a tree view control in Access, and thought that my next task would follow a combination of these two, in putting images in a list box. Reading on the internet pointed me in the direction of listviews.

I have the following code, on_load in my form.

Me.imgList1.ListImages.Add 1, "MAIN", LoadPicture("MAIN_ICON.bmp")
Me.imgList1.ListImages.Add 2, "SUB", LoadPicture("SUB_ICON.bmp")
lstView1.View = lvwSmallIcon
lstView1.Icons = imgList1

However i get an invalid object on the following line

lstView1.Icons = imgList1

Could anyone advise of the correction? This is my 1st time using these.

TIA

Nathan
 
I load the images into the ImageList in design view. Then it's loaded and I don't need the image files anymore. And I don't need the code you're working on.
You might be getting an error because technically your imgList1 object is a customcontrol that contains the ActiveX ListView. You need to assign the object in the control, as follows...
Code:
Me.ListView0.Icons = me.imgList1.Object
...and since it's an object assignment you might also need ...
Code:
Set Me.ListView0.Icons = me.imgList1.Object
But what I almost always do, so that I get to use intellisense on those ActiveX objects is declare a local, strongly typed variable, and then assign to it, or them, the objects in the controls. Consider ...
Code:
private withevents m_list as mscomctllib.ListView

private sub form_open(cancel as integer)
  set m_list = me.listview0.object
[COLOR="Green"]  'from now on refer to the ListView as m_list, which is supported by intellisense
[/COLOR]  set m_list.icons = me.imagelist0.object
  set m_list.smallicons = m_list.icons
end sub
Cheers,
 

Users who are viewing this thread

Back
Top Bottom