473,396 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Referencing Images...

Tom
I need to be able to reference some images stored in my VB.NET program.
Normally, I would load the images into an ImageList control and use
them from there (these are going to be icons). However, I need to be
able to add/delete images from this image 'store' (whatever I end up
using); but because an image list only allows referencing by image
number in the list, when I would delete an image/icon it would 'mess'
up the ones following that because obviously the image number would
change. Also, I want to allow the user to load custom images/icons of
their own, which again (especially when deleting images) would allow
things to get screwed up because the image number would be affected
(i.e. in the program I would allows my main database records to 'store'
the key to an image - if that key is simply the image number in the
image list, then it is going to be incorrect if any image before that
gets deleted).

In the old VB 6 ImageList one could assign each image a 'key' - but
that isn't used in the new .NET image list. There has got to be a way
to store some kind of unique key to an image and then use that key
(perhaps a hash list or something). Anyone got a good way to handle
this? THanks in advance.

Chimp

--

May 23 '06 #1
2 3811
You can use a Dictionary to do this, assigning some key and storing Images:

Imports System.Collections.Generics

....

Private m_Images As New Dictionary(Of Integer, Image)
....
....
Images .Add ( 21, theImage )
....
....
myImage = Images ( 21 )
....
....
Images .Remove ( 21 )
....
....


"Tom" <to*@nospam.com> wrote in message
news:ew**************@TK2MSFTNGP03.phx.gbl...
I need to be able to reference some images stored in my VB.NET program.
Normally, I would load the images into an ImageList control and use
them from there (these are going to be icons). However, I need to be
able to add/delete images from this image 'store' (whatever I end up
using); but because an image list only allows referencing by image
number in the list, when I would delete an image/icon it would 'mess'
up the ones following that because obviously the image number would
change. Also, I want to allow the user to load custom images/icons of
their own, which again (especially when deleting images) would allow
things to get screwed up because the image number would be affected
(i.e. in the program I would allows my main database records to 'store'
the key to an image - if that key is simply the image number in the
image list, then it is going to be incorrect if any image before that
gets deleted).

In the old VB 6 ImageList one could assign each image a 'key' - but
that isn't used in the new .NET image list. There has got to be a way
to store some kind of unique key to an image and then use that key
(perhaps a hash list or something). Anyone got a good way to handle
this? THanks in advance.

Chimp

--

May 24 '06 #2
On Tue, 23 May 2006 13:54:21 -0700, "Tom" <to*@nospam.com> wrote:
I need to be able to reference some images stored in my VB.NET program.
Normally, I would load the images into an ImageList control and use
them from there (these are going to be icons). However, I need to be
able to add/delete images from this image 'store' (whatever I end up
using); but because an image list only allows referencing by image
number in the list, when I would delete an image/icon it would 'mess'
up the ones following that because obviously the image number would
change. Also, I want to allow the user to load custom images/icons of
their own, which again (especially when deleting images) would allow
things to get screwed up because the image number would be affected
(i.e. in the program I would allows my main database records to 'store'
the key to an image - if that key is simply the image number in the
image list, then it is going to be incorrect if any image before that
gets deleted).

In the old VB 6 ImageList one could assign each image a 'key' - but
that isn't used in the new .NET image list. There has got to be a way
to store some kind of unique key to an image and then use that key
(perhaps a hash list or something). Anyone got a good way to handle
this? THanks in advance.

Chimp


If you manage to add images in Design to an ImageList componet
(doesn't work, here), you should be able to add keys at runtime:

ImageList1.Images.SetKeyName(index, "SomeKey")

By your description, it may better to simply populate the ImageList at
runtime:
ImageList1.Images.Add("SomeKey", SomeImage)

To delete:
ImageList1.Images.RemoveByKey("SomeKey")

Gene
May 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Simon | last post by:
Am using the following code. <script language="JavaScript1.2"> function setquantity(productindex,productquantity) { //create the reference object irefname_none = eval("document." +...
1
by: Lucanus | last post by:
Hi All, Just a quick question, which should have a simple answer... Can I have a document with three images with the same name, and reference those images individually. ie: <img...
2
by: RWC | last post by:
Hello, I have a page connected to an SQL table. The page loops through, creating a row for each record, displaying in image, the ID of which is set to the record id. When I click a button to...
6
by: Mikey_Doc | last post by:
Hi We are running cms 2002, Framework 1.0 with Visual studio 2002. We have just upgraded to Framework 1.1 and visual studio 2003. All of our database connection strings are stored within the...
1
by: WB | last post by:
Hi, I would like to do something like this page: http://www.stocklayouts.com/Products/Postcard/Postcard-Template-Design-Library.aspx?kwid=38 Notice when you mouse-over any of the icons under...
2
by: oroojo | last post by:
Hi i have the following code that works fine in firefox but not IE? function imgLoad () { test = new Image(); test = "../gfx/nav_es/areas_over.gif"; document.getElementById('test').src =...
3
by: Torsten Wiebesiek | last post by:
Hi folks, currently I'm writing image classes for easier handling of Intel's IPP library. My idea is to have to different classes. One class that represents a complete image and deals with all...
6
by: wangers16 | last post by:
Hi all, I have the following array with which I need to reference to the second item in every array and write it out onto the page, how can this be done? var arr = new Array(); arr =...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.