Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I didn't use Graphics objects before and have a problem:

I have 2 icons with .ico extension and I think I have to import them to my project resources!

Then on my forl load event I want to choose which icon will be shown as the form icon property.

I was not able to implement this simple task!

Can anyone any help?

Posted

Resources files

 

Add a resources file to your project, then import the two icons as resources. The code for a strongly-typed resource class will be automatically generated, and you can then use the class to set the Icon property of the form:

 

If (somecondition) Then
   Me.Icon = MyResourcesClass.Icon1
Else
   Me.Icon = MyResourcesClass.Icon2
End If

 

Good luck :cool:

Never trouble another for what you can do for yourself.
  • Leaders
Posted
The code for a strongly-typed resource class will be automatically generated

 

This is assuming that we are using a 2.0 version of VS. If you are using version 1.x you need to add the icon to your project, set the compile action to embedded resource, and use the Assembly.GetManifestResourceStream function to get a System.IO.Stream object that you can pass to the System.Drawing.Icon constructor. Of course, you will need more than a brief summary of the process, but I believe that there is a tutorial in the Tutor's Corner section of the forum.

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...