Store your icons in a DLL file

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
8 posts Page 1 of 1
Contributors
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Store your icons in a DLL file
XTechVB
in this tutorial i'll show you how to add images/icons to a dll file then use them in your app.

1. first will make the the dll file
create a new class library project the go to MyProject > Resources > Images > Add Resource > Add Existing File (add as many resources you want)

then under your Public Class write this code
Code: Select all
    Public Shared Function Button1Image() As System.Drawing.Bitmap
        Return My.Resources.btn1Image 'replace btn1 with the name of your image
    End Function
now compile your project

2. Create a Windows Form Project(and reference the dll you've just created)
add a button or a picturebox whatever supports "Image" or "BackgroundImage"
then in your form load event add this code
Code: Select all
Button1.Image = myDll.Class1.Resources.btn1Image
That's It

Simple but i believed it was worth sharing.
You can find me on Facebook or on Skype mihai_92b
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: Store your icons in a DLL file
MrAksel
It might be simple, but it's wrong. In the form load event, you would have
Code: Select all
Button1.BackgroundImage = myDll.Class1.Button1Image()
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Re: Store your icons in a DLL file
XTechVB
MrAksel wrote:
It might be simple, but it's wrong. In the form load event, you would have
Code: Select all
Button1.BackgroundImage = myDll.Class1.Button1Image()
yes, and why is it wrong?
You can find me on Facebook or on Skype mihai_92b
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: Store your icons in a DLL file
MrAksel
You have the wrong code in your topic. It should be replaced with what I posted.
You do not have any nested class named "Resources" inside Class1.
Just look at your code and try to compile it and you will see :)
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Hey
Yeah a great tutorial and it worked first time for me :)

nice

Chris
Image
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

Re: Store your icons in a DLL file
Shim
hungryhounduk wrote:
Hey
Yeah a great tutorial and it worked first time for me :)

nice

Chris

wow :D i am searching this for a month in total now i got the tutorial(Store your icons in a DLL file) , thank you so much


clapper; wahooo;
Find my programs on Softpedia
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Just been messing with it
Code: Select all
 Button1.BackgroundImage = ClassLibrary6.Class1.Button1Image()
        Button2.BackgroundImage = ClassLibrary6.Class1.Button2Image()
        Button3.BackgroundImage = ClassLibrary6.Class1.Button3Image()
        Button4.BackgroundImage = ClassLibrary6.Class1.Button4Image()
        Button5.BackgroundImage = ClassLibrary6.Class1.Button5Image()
        Button1.BackgroundImageLayout = ImageLayout.Center
        Button2.BackgroundImageLayout = ImageLayout.Center
        Button3.BackgroundImageLayout = ImageLayout.Center
        Button4.BackgroundImageLayout = ImageLayout.Center
        Button5.BackgroundImageLayout = ImageLayout.Center
added 5 buttons and it all works really well

Chris
Image
User avatar
MrAlicard
VIP - Donator
VIP - Donator
Posts: 54
Joined: Thu Aug 05, 2010 4:08 pm

Thanks man. :D
You helped me a lot dude. :)
8 posts Page 1 of 1
Return to “Tutorials”