473,854 Members | 1,436 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3927
* "Juan Romero" <ju*********@bo wne.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.Imag es.Contains(Bit map1) 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******** ******@TK2MSFTN GP10.phx.gbl...
* "Juan Romero" <ju*********@bo wne.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.Imag es.Contains(Bit map1) Then
...
Else
...
End If
///

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

Nov 20 '05 #3
"Juan Romero" <ju*********@bo wne.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*********@bo wne.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******** ******@TK2MSFTN GP10.phx.gbl...
* "Juan Romero" <ju*********@bo wne.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*********@bo wne.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*******@free net.de> wrote in message
news:Ol******** ******@TK2MSFTN GP10.phx.gbl...
"Juan Romero" <ju*********@bo wne.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*********@bo wne.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/frlrfSystemWind owsFormsImageLi stImageCollecti onClassAddTopic 1.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*********@bo wne.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

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

Similar topics

4
3739
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 valid until you called "DestroyIcon()". If you didn't, you had a leak. In C#, I need to load icons from unmanaged programs (.exe, dll) at run time and I want to make sure I'm not leaking resources, but it's not clear to me how to insure that I'm...
3
6587
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 32bpp non-xp icon (no transparency), and a 16x16 version. I add these icons to an ImageList, which is then assigned to the LargeImageList property of the ListView.
3
2762
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 icons are added to two ImageList objects which are bound to a ListView control, and everything looks great. I am saving the icons to a SQL Server table by using Icon.Save to a stream and assigning the byte array to the field, then loading them...
2
19884
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
11015
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: statusBarPanel1.Icon = imageList1.Images; // cast/as don't work // Cannot convert type 'System.Drawing.Image' to 'System.Drawing.Icon' What am I mising here?
4
3838
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 associated icons. While I am able to list the programs correctly, the icons that get displayed alongside are the ones for the folders. The form has listview and imagelist controls on it. I shall paste the code here. 2) I was also wondering why...
1
3846
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
4950
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... >>; treeViewImageList.Images.Add("abc", sourceIcon); But when I first save the original icon to a stream and then try loading the
7
2351
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 = Drawing.Icon.ExtractAssociatedIcon("file.exe").ToBitmap The problem is I need the icon not the bitmap.
0
9751
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10371
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9513
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7915
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7082
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5942
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4562
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4159
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3187
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.