Jump to content
Xtreme .Net Talk

Recommended Posts

  • Leaders
Posted

to add a new icon in c-sharp you can do this :

private void menuItem1_Click(object sender, System.EventArgs e)
{
	this.Icon=new Icon("C:\\7.ico"); '/// your icon path where it says "C:\\7.ico"
}

just incase anyone's interested :)

Posted
hmm, another question, my program will crash if i do not move the icon file with the application, I was hoping that the icon would get compiled right into the code and then be pulled from there, what should I do?? I tried including the file in the project (using sharpdevelop .95) but it did not work. Any suggestions??
  • *Gurus*
Posted

Yeah, get a better IDE :P

 

Seriously, all you have to do is embed the icon in your project and then retrieve it at runtime and assign it to the form. SharpDevelop's Form Editor should take cake of this for you - if it's not, I would suggest posting on their forums as this seems to be an IDE issue.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

C#

 

[*]Embed the icon file as a resource in the application executable, using the appropriate command-line switch: /res:Blah.ico

[*]Set the form's icon, something like this:


Icon = new Icon(GetType().Assembly.GetManifestResourceStream("Blah.ico"));

[/list=1]

 

Voilà!

  • *Experts*
Posted

Dim ico As New Icon(System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream("NamespaceName.YourIcon.ico"))

Substitute the NamespaceName with the name of the namespace your project is in.

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...