Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

ToolBar and ImageList

I am new to Visual Basic. So the differences between C++ and VB are striking to me. But even this seems like too much. Here is what I am talking about:

I got a project out of source safe and I started working with it.
The Graphics associated to an image list had been compiled into the project but the actual graphic files were missing.
So they appeared in the project at first but then the buttons associated with the image list went blank.
I thought all I had to do was to get the graphic image files and then reassign the image list and the toolbar. But NOOOOO. According to the book I have, once the image is set, you cannot change it and you will have to build the entire thing from scratch.

Is this right?

----------

OK, so I went ahead and wrote down all the key names and other data associated with the image list and the button bar and I went ahaead and deleted them. I have made a back-up copy of the project in case I want to go return to the version before I did this.

But now, after inserting each bitmap into the ImageList, I right-clicked on the new Toolbar and choose Properties and assigned it the ImageList.

Now, aren't the images supposed to pop into the toolbar?

What am I doing wrong?
[1286 byte] By [Complete] at [2007-11-11 7:46:00]
# 1 Re: ToolBar and ImageList
Does anyone know where I can find a good tutorial showing how to use Visual Basic ToolBar and ImageList?
Complete at 2007-11-11 17:26:30 >
# 2 Re: ToolBar and ImageList
Complete, I think you are mis-informed as to the relationship between the ImageList and the Toolbar. The only thing you cannot do with the ImageList is add or subtract images while it is referenced to the Toolbar.

So take an empty ImageList (ImageList1 for example), fill it with images (you can select more than one at once). Open the Toolbar Properties and on the main page select ImageList1 in the ImageList Combo.

Now as you add buttons, or, if they are already there, select the image number for each button in the button's property page.

If you need at some later date to modify the imagelist, just remove the Toolbar reference and modify the Imagelist then re-establish the references again.

I have just tried this and it works.

I hope you find this helpful.

Steve.
Steve Grant at 2007-11-11 17:27:30 >
# 3 Re: ToolBar and ImageList
I got the buttons (their graphic image) back to the toolbar.

And when you click on the buttons, the right VB code is executed through a switch statement, etc.

So I am just about there.

The only problem now is that when I click on a button, it does not stay clicked. Any idea why that is? I looked at the properties of the toolbar but I cannot find any sort of thing that suggests that a button should stay down once you click it.

In other words, when the toolbar comes up, the first button appears as being pressed down. And if a user clicks on any other buttons, he can do so, but once he let's go, the first button goes back to being the only one pressed down.
Complete at 2007-11-11 17:28:28 >
# 4 Re: ToolBar and ImageList
Complete, you don't mention whether you can push button 1 and it will come up and stay up. The only way I can make a button do as you describe, is to set it's value to 1 (Pressed), in which case it stays down until you click it and then performs normally, or to set it's type to 1 (Check) and it only stays down once clicked.

One other thought, have you set the disabled or hot imagelists, I remember reading a long time ago about a strange problem occuring if these were set.

More Info please.

Edit: Of course this could be happening through code, but I bet you've checked for that!

Steve.
Steve Grant at 2007-11-11 17:29:30 >