Send a suggestion!

We're building a brand new version of the site, and we'd love to hear your ideas

Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 76,184 times

Contents

Related Categories

Image List Control - Adding Images

Adding Images

Firstly, we need to add some images to the ImageList control. To do this, right click on the ImageList control that you have added to the form, and click Properties. The Property Pages for the ImageList control will now appear:

Click on the Images tab, and click Insert Picture. There are a number of standard toolbar buttons provided with Visual Basic. Browse to %VBInstallationPath%CommonGraphicsBitmapsTlBr_W95. This path may differ depending on where VB is installed, and if you have the whole of Visual Studio installed. If you can't find it, simply use the Windows search tool to find the folder TlBr_W95. 

You can insert more than one image at a time, so, simply select a few of the BMP files in the TlBr_W95 folder, using the Shift and Ctrl keys, and click Open. You will now see that they are shown under the label Images in the Property Pages. 

If you get an error saying "ImageList cannot be modified while another control is bound to it", select the last image, and then add the images. This error occurs because another Common Control is using the Images in the ImageList control (called being bound), and therefore you can only add images to the end. Also, once the ImageList is bound to another control, you cannot delete any images. If you need to do this, select the control that is bound to it, and change its ImageList property to <None>. Make the changes you want to the ImageList, and bind it again.

Now you need to set the keys for each of the images. Select the first image, and type some text in the Key field to identify it. For example, if it is a picture of the 'Copy' image, enter copy. It is a good idea to use the same case for all the keys (ie all uppercase or all lowercase), because it is case-sensitive. Enter keys for all the other images you have added, and click OK. 

You have now successfully added some images to the ImageList control.

James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.

Comments

  • Visual Basic

    Posted by Anuradha on 23 Jul 2002

    I am new to VB and I am sort working thru exercises in a book

    I came across one that has me a bit stuck
    It basically says to create a form with two ImageList Controls ,add the images to one con...

  • Posted by battleangel444 on 18 Apr 2002

    hey i hope this helps i was tryin to do the same thing you were tryin to do and i stuble upon your topic, try using this

    ImageList1.ListImages.Add ImageList1.ListImages.count + 1, , LoadPicture(txt...

  • dynamically populating imagelist

    Posted by theoskii on 09 Apr 2002



    I am very new to VB and I am sort working thru exercises in a book

    I came across one that has me a bit stuck
    It basically says to create a form with two ImageList Controls populate the first ...