473,385 Members | 2,180 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,385 software developers and data experts.

Convert Image to Icon

I wish to set Form.Icon from an image list but seems like the image list
didn't provide a method to extract the image as an Icon type.

Thus, can anyone show me a way the conversion
From: System.Drawing.Image
To: System.Drawing.Icon

Or show me an easy way to set the Form.Icon from an image list.
Thanks and have a nice day.
Nov 20 '05 #1
3 21608
Cor
Hi Stanley,
Did you use the drag method from your toolbox to use the imagelist?
In my opinion that is for this the far out the most simple method.
When you fill with the properties from the designer the imagelist with your
icons, they will be put as bitmaps in the resources.
After you have done that you can bind your image to your controls using the
design properties or dynamicly.
(Therefore I don't have a preference)
Dynamicly you can use the imagelist and imageindex properties to tell what
imagelist has to be used and what is the index.
I hope this helps a little bit.
Cor
Nov 20 '05 #2
"Stanley" <se****@email.com> schrieb
I wish to set Form.Icon from an image list but seems like the image
list didn't provide a method to extract the image as an Icon type.

Thus, can anyone show me a way the conversion
From: System.Drawing.Image
To: System.Drawing.Icon

Or show me an easy way to set the Form.Icon from an image list.
Thanks and have a nice day.


Type-cast the image to Bitmap, then use the bitmap's GetHIcon method to get
the icon handle. Pass it to System.Drawing.Icon.FromHandle
--
Armin

Nov 20 '05 #3
"Stanley" <se****@email.com> scripsit:
I wish to set Form.Icon from an image list but seems like the image list
didn't provide a method to extract the image as an Icon type.

Thus, can anyone show me a way the conversion
From: System.Drawing.Image
To: System.Drawing.Icon

Or show me an easy way to set the Form.Icon from an image list.


You may want to store the icons as embedded resources instead of an imagelist.

Add the icon file to your project and set its 'Build Action' property to 'Embedded Resource'. You can use the code below to load the icon at runtime:

\\\
foo.Icon = _
New Icon( _
[Assembly].GetExecutingAssembly().GetManifestResourceStream( _
"WindowsApplication1.Ball.ico" _
) _
)
///

'WindowsApplication1' is the root namespace of the application, "Ball.ico"
is the icon's filename.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

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

Similar topics

0
by: yxq | last post by:
Please add the manifest file! ************************************************************* Imports System Imports System.Drawing Imports System.Runtime.InteropServices Module Module1 Public...
8
by: news.microsoft.com | last post by:
I have an icon that I can reference by the following: Dim im As System.Drawing.Image im = im.FromFile(lsapppath & "ChkMrk.ico") g_mainform.fg.SetCellImage(g_mainform.FG.Row, 5, im) The problem...
4
by: Bill English | last post by:
Does anyone have any ideas for converting an image file to an icon? The icon I want have for my App is currently an image.
5
by: jcrouse | last post by:
I saw an article, once, on how to package image file in the installer so they are not accessible to the end user. I want to say hidden, but I don't just mean the file attribute of the image file....
3
by: Jason Barnett | last post by:
When trying to save an image as an icon, I've used the following line of code (img is an System.Drawing.Image)... img.Save("C:\output.ico", ImageFormat.Icon) The files saves without an error,...
5
by: Socrates | last post by:
I am interested in developing an online utility that will enable users to copy and past any image (or upload any image on the internet) to the online utility, which will then convert the image to...
2
by: Marc Solé | last post by:
Hello, I want to insert an image to a specific column of a dataGridWiew. I explain what I'm doing: - I define the ColumnType as a DataGridViewImageColumn. - I select the image (an icon of...
2
by: HKSHK | last post by:
Hello, I've got this problem: I loaded an icon (with alpha and smoothing) into a graphics object. Now I want to display it. The best solution would be if I could convert it into an image...
4
by: Mark | last post by:
Hi I notice that in some cases, to get an icon, an object (for example a list view) uses an image list, in others (e.g. a form) the image is selected from the project resources, i.e. a file. ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.