imagelist isnt initialized problem...
I have a toolbar and an imagelist control assigned to it. I load images into the imagelist and create buttons in the toolbar in runtime.
Dim listimg_temp As ListImage
Set listimg_temp = ImageList1.ListImages.Add(...)
Dim btn As Button
Set btn = Toolbar1.Buttons.Add(...)
but sometimes I need to clear both of them and recreate them in runtime again.
Toolbar1.Buttons.Clear
ImageList1.ListImages.Clear 'ERROR! why? and how to solve this?
plz help
Re: imagelist isnt initialized problem...
You can't delete or insert images to an imagelist that have been bound to a toolbar (you can add images to the end of the collection but not insert images). So what you have todo is to set the ImageList property of the Toolbar to nothing before you clear the images.
VB Code:
Toolbar1.Buttons.Clear
Set Toolbar1.ImageList = Nothing
ImageList1.ListImages.Clear
Set Toolbar1.ImageList = ImageList1
Re: imagelist isnt initialized problem...
Quote:
Originally Posted by Joacim Andersson
You can't delete or insert images to an imagelist that have been bound to a toolbar (you can add images to the end of the collection but not insert images). So what you have todo is to set the ImageList property of the Toolbar to nothing before you clear the images.
VB Code:
Toolbar1.Buttons.Clear
Set Toolbar1.ImageList = Nothing
ImageList1.ListImages.Clear
Set Toolbar1.ImageList = ImageList1
yes. I have tried exactly the same too, but it also doesnt work.
the line:
Set Toolbar1.ImageList = ImageList1
cause error: Imagelist must be initialized before it can be used!
Re: imagelist isnt initialized problem...
Oh yeah sorry. You must add at least one image to the ImageList before you can set it back to the Toolbar.
Re: imagelist isnt initialized problem...