ADO DOT NET Posted January 5, 2007 Posted January 5, 2007 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? Quote
Administrators PlausiblyDamp Posted January 5, 2007 Administrators Posted January 5, 2007 Could you show what code you have so far? What language are you using VB / C#? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
MrPaul Posted January 5, 2007 Posted January 5, 2007 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: Quote Never trouble another for what you can do for yourself.
Leaders snarfblam Posted January 5, 2007 Leaders Posted January 5, 2007 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. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.