473,394 Members | 1,734 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,394 software developers and data experts.

Check for icon in ImageList

Hey guys,

I have an ImageList control that stores my icons. What I need to do is find
out if the icon at hand already exists in the ImageList so I dont enter it
twice. How can I do that?

Thanks in advance!
Nov 20 '05 #1
11 3886
* "Juan Romero" <ju*********@bowne.com> scripsit:
I have an ImageList control that stores my icons. What I need to do is find
out if the icon at hand already exists in the ImageList so I dont enter it
twice. How can I do that?


\\\
If ImageList1.Images.Contains(Bitmap1) Then
...
Else
...
End If
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Thanks for answering.

The contains method is not supported in VB.NET.
What I have in the image list is not a bitmap or image, but AN ICON. That is
why it is so difficult.
Any other ideas anyone out there?

Thanks in advance.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eR**************@TK2MSFTNGP10.phx.gbl...
* "Juan Romero" <ju*********@bowne.com> scripsit:
I have an ImageList control that stores my icons. What I need to do is find out if the icon at hand already exists in the ImageList so I dont enter it twice. How can I do that?


\\\
If ImageList1.Images.Contains(Bitmap1) Then
...
Else
...
End If
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #3
"Juan Romero" <ju*********@bowne.com> schrieb
Thanks for answering.

The contains method is not supported in VB.NET.
What I have in the image list is not a bitmap or image, but AN ICON.
That is why it is so difficult.
Any other ideas anyone out there?

An imagelist contains images, not icons. An icon is not an image. Images are
Bitmaps or Metafiles.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4
* "Juan Romero" <ju*********@bowne.com> scripsit:
The contains method is not supported in VB.NET.
Sorry, I read that later in the docs...
What I have in the image list is not a bitmap or image, but AN ICON. That is
why it is so difficult.


An imagelist cannot store icons. How do you add them?!

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5
Well, believe it or not, you ARE IN FACT able to add icons to the list.
One of the declarations of the "add" method of the images collection of the
imagelist accepts a system.drawing.icon as a parameter.

Check it out.

Thanks!

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eQ**************@TK2MSFTNGP10.phx.gbl...
* "Juan Romero" <ju*********@bowne.com> scripsit:
The contains method is not supported in VB.NET.


Sorry, I read that later in the docs...
What I have in the image list is not a bitmap or image, but AN ICON. That is why it is so difficult.


An imagelist cannot store icons. How do you add them?!

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #6
"Juan Romero" <ju*********@bowne.com> schrieb
Well, believe it or not, you ARE IN FACT able to add icons to the
list. One of the declarations of the "add" method of the images
collection of the imagelist accepts a system.drawing.icon as a
parameter.

Check it out.


Yes, but it is converted to a bitmap.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #7
Correct, which is exactly my problem, how do I compare the bitmap to the
icon?
Don't forget that what I want to do is to find out if a particular icon has
been entered into the imagelist (even if it was converted to a bitmap).
There is no conversion from bitmap to icon or viceversa, or maybe there is
and I dont know about it?

Thanks!

"Armin Zingler" <az*******@freenet.de> wrote in message
news:Ol**************@TK2MSFTNGP10.phx.gbl...
"Juan Romero" <ju*********@bowne.com> schrieb
Well, believe it or not, you ARE IN FACT able to add icons to the
list. One of the declarations of the "add" method of the images
collection of the imagelist accepts a system.drawing.icon as a
parameter.

Check it out.


Yes, but it is converted to a bitmap.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #8
* "Juan Romero" <ju*********@bowne.com> scripsit:
Well, believe it or not, you ARE IN FACT able to add icons to the list.
One of the declarations of the "add" method of the images collection of the
imagelist accepts a system.drawing.icon as a parameter.

Check it out.


<http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWindowsFormsImageListImageCollectionCla ssAddTopic1.asp>

<msdn>
Remarks

The Icon is converted to a Bitmap before it is added to the list.
</msdn>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #9
"Juan Romero" <ju*********@bowne.com> schrieb
Correct, which is exactly my problem, how do I compare the bitmap to
the icon?
Don't forget that what I want to do is to find out if a particular
icon has been entered into the imagelist (even if it was converted to
a bitmap). There is no conversion from bitmap to icon or viceversa,
or maybe there is and I dont know about it?


I guess I didn't understand the question. To find out if the image has been
inserted in the imagelist, you must have a look at the content of the
imagelist.

Maybe Herfried knows the answer.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #10
Yes.....
The problem is that I am inserting ICONS. Icons get converted into bitmaps,
so once the icon is in there, there is no way I can check it.

For instance, suppose I add "iconA" to the imagelist. I don't want to have
the same icon more than once on that imagelist, so the next time I add an
icon, I want to be able to check if the icon exists already in the list. The
problem is that when the icon is inserted into the list, it is converted and
stored as a bitmap, so when I check, I end up comparing AN ICON AGAINST A
BITMAP. So the issue is how do I make this work out. The only possible way I
see is to convert one of them to the opposite format, WHICH IS NOT POSSIBLE,
or at least I dont know how.

If anyone knows how, or an alternative way of dealing with this, please let
me know.

Thanks!
"Armin Zingler" <az*******@freenet.de> wrote in message
news:Oa**************@TK2MSFTNGP09.phx.gbl...
"Juan Romero" <ju*********@bowne.com> schrieb
Correct, which is exactly my problem, how do I compare the bitmap to
the icon?
Don't forget that what I want to do is to find out if a particular
icon has been entered into the imagelist (even if it was converted to
a bitmap). There is no conversion from bitmap to icon or viceversa,
or maybe there is and I dont know about it?
I guess I didn't understand the question. To find out if the image has

been inserted in the imagelist, you must have a look at the content of the
imagelist.

Maybe Herfried knows the answer.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #11
Hi Juan,

Does this answer your question:
' Retreive Bitmap from imageList

Dim bmp As Bitmap = DirectCast(Me.imgICO16.Images(1), Bitmap)

' Convert bitmap to Icon

Dim ico As Icon = Icon.FromHandle(bmp.GetHicon)

' Perform your logic

HTH,

Michael

"Juan Romero" <ju*********@bowne.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
| Yes.....
| The problem is that I am inserting ICONS. Icons get converted into
bitmaps,
| so once the icon is in there, there is no way I can check it.
|
| For instance, suppose I add "iconA" to the imagelist. I don't want to have
| the same icon more than once on that imagelist, so the next time I add an
| icon, I want to be able to check if the icon exists already in the list.
The
| problem is that when the icon is inserted into the list, it is converted
and
| stored as a bitmap, so when I check, I end up comparing AN ICON AGAINST A
| BITMAP. So the issue is how do I make this work out. The only possible way
I
| see is to convert one of them to the opposite format, WHICH IS NOT
POSSIBLE,
| or at least I dont know how.
|
| If anyone knows how, or an alternative way of dealing with this, please
let
| me know.
|
| Thanks!
|
|
| "Armin Zingler" <az*******@freenet.de> wrote in message
| news:Oa**************@TK2MSFTNGP09.phx.gbl...
| > "Juan Romero" <ju*********@bowne.com> schrieb
| > > Correct, which is exactly my problem, how do I compare the bitmap to
| > > the icon?
| > > Don't forget that what I want to do is to find out if a particular
| > > icon has been entered into the imagelist (even if it was converted to
| > > a bitmap). There is no conversion from bitmap to icon or viceversa,
| > > or maybe there is and I dont know about it?
| >
| > I guess I didn't understand the question. To find out if the image has
| been
| > inserted in the imagelist, you must have a look at the content of the
| > imagelist.
| >
| > Maybe Herfried knows the answer.
| >
| >
| > --
| > Armin
| >
| > http://www.plig.net/nnq/nquote.html
| > http://www.netmeister.org/news/learn2quote.html
| >
|
|
Nov 20 '05 #12

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

Similar topics

4
by: Terry | last post by:
There are a number of things about using unmanaged resources in Windows Forms programming that is unclear to me. In C++, if you loaded an icon resource using "ExtractIcon()", the resource was...
3
by: scoobydoo | last post by:
hi, I have a problem displaying icons at the right colour depthin a ListView. I've made an icon file, (using IconWorkshop 5), it has 3 icons within it. A 32x32 32bpp XP style icon, a 32x32...
3
by: Tony Lugg | last post by:
I have an application with a document management form. When users add documents to the form, I call the API function SHGetFileInfo to get the associated large and small icons for the file. These...
2
by: Mamatha | last post by:
Hi I want to add an icon to the textbox's text. I don't know how to display icon in textbox in VB.NET. If any one knows please let me know. Thanks in advance. Mamatha
6
by: Udi | last post by:
Hi, I have an imagelist initialized in design time with several icons files (.ico). However, when I need to extract an icon (Image) from the Imagelist, I can't convert it back to an icon: ...
4
by: techspirit | last post by:
Hi all, 1) I found out from the vb.net group that it is possible to get an associated icon for a file. My requirement is to display all programs from the Start Menu for the user along with the...
1
by: Steph. | last post by:
Hi, I load Icons in an ImageList.To do that I have to convert the Icons in the Bitmap format. But HOW can I get My Icon back in a Usable Icon format ?
1
by: =?Utf-8?B?QWRhbQ==?= | last post by:
I'm having a problem loading an Icon into an ImageList. When I load the icon directly it works fine, like this: Icon sourceIcon = << Get an icon from somewhere... >>;...
7
by: =?Utf-8?B?QmVu?= | last post by:
Hi I am looking for a way to extraxt an icon from a .exe file an save it as an icon not a bitmap or jpeg to a file? The code below extracts the icon but only as a bitmap PictureBox1.Image =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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.